Solved

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

Posted on 2006-11-28
2
672 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.

749 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