Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
Hello,
 
I was asked to make a program where there is 3 listboxes, the 1st one has the list of names, the 2nd one should have the first name with lower case and the 3rd should have the last name in Upper case.
 
My problem is i double clicked on the 1st listbox( the one with names) and wrote this code
**names
John Green
Malcolm Jackson
listbox2.items.Add(listbox1.selecteditem.substring(0,3)
listbox3.items.add(listbox1.selecteditem.substring(5,6)
 
My problem is how to i have a seperate substring with different names, because the one above works only for the first names>??
2nd Question how can u have a listbox with cases whether its upper or lower.
 
Thnks
Posted 17-Feb-13 19:57pm
Edited 18-Feb-13 7:03am
v2
Comments
Sergey Alexandrovich Kryukov at 18-Feb-13 1:08am
   
Which of the types named "ListBox" do you mean? Full name, please. And tag your application type or UI library.
—SA
Karthik Harve at 18-Feb-13 1:20am
   
do you mean, once the full name is selected in first list box, the other list boxes must filled with first and last names respectively. is that your problem ?
Iman90 at 18-Feb-13 1:32am
   
Yes, exactly that but also have the first name in lower case and the last name in upper case

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hi,
Check the below code
 
Private Sub ListBox1_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.DoubleClick
        If (ListBox1.SelectedIndex <> -1) Then
            Dim info(2) As String
            'Split the Firstname and Lastname using space
            info = ListBox1.SelectedItem.ToString().Split(" ")
            Dim fName As String = info(0) 'FirstName
            Dim lName As String = info(1) 'LastName

            ListBox2.Items.Add(fName.ToLower()) 'Convert to lower
            ListBox3.Items.Add(lName.ToUpper()) 'Convert to Upper

 
        End If
    End Sub
 
Best Regards
Muthuraja
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 480
1 Maciej Los 290
2 Richard MacCutchan 225
3 BillWoodruff 185
4 Suraj Sahoo | Coding Passion 155
0 OriginalGriff 8,764
1 Sergey Alexandrovich Kryukov 7,437
2 DamithSL 5,639
3 Maciej Los 5,279
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web03 | 2.8.1411028.1 | Last Updated 18 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100