Solved

extracting a string from a combobox text string - vb.net 2003

Posted on 2006-11-28
2
670 Views
Last Modified: 2012-06-27
Hi Experts,

I have a combobox on a winform which has ITEMS of names displayed in the format of "surname, firstname".  When a name is selected from the combobox, I'd like to display just the firstname in Textbox1.text.

Textbox1.text = "Hi " & string = "firstname (only)" from combobox1.text

It's important that the format of the combobox be kept intact.  I've goofed around with code, but need a little help.

Cheers,
Roberto
0
Comment
Question by:RobertoFreemano
2 Comments
 
LVL 23

Accepted Solution

by:
gecko_au2003 earned 50 total points
ID: 18032508
Dim i As String = combobox1.text
    Dim a() As String
    Dim j As Integer
    a = i.Split(",")
    For j = 0 To a.GetUpperBound(0)
    MsgBox(a(j))
    Textbox1.text= a(j)
    Next

Put that in the click event of the combo box and if it works then just comment out the messagebox in the for next loop :)
0
 

Author Comment

by:RobertoFreemano
ID: 18035185
Thanks, gecko_au2003
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is an explanation of a simple data model to help parse a JSON feed
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question