ListBox程序传输名称 [英] ListBox Program transfering names
问题描述
您好,
我被要求制作一个有3个列表框的程序,第一个有名单,第二个有第一个名字用小写,第3名应该用大写的姓氏。
我的问题是我双击第一个列表框(名字有一个)并写了这段代码
**姓名
John Green
Malcolm Jackson
listbox2 .items.Add(listbox1.selecteditem.substring( 0 , 3 )
listbox3.items .add(listbox1.selecteditem.substring( 5 , 6 )
我的问题是如何使用不同名称的单独子字符串,因为上面的字符串仅适用于名字> ??
2nd问你如何拥有一个列表框,其中包含上限或下限的情况。
Thnks
您好,
检查以下代码
私有 Sub ListBox1_DoubleClick( ByVal sender 作为系统。对象, ByVal e 正如 System.EventArgs)句柄 ListBox1.DoubleClick
If (ListBox1.SelectedIndex <> -1)然后
Dim info( 2 )作为 字符串
' 使用空格分割名字和姓氏
info = ListBox1.SelectedItem.ToString()。分割( )
Dim fName 作为 字符串 = info( 0 )' FirstName
Dim lName 正如 字符串 = info( 1 ) ' 姓氏
ListBox2.Items.Add(fName.ToLower())' 转换为低位
ListBox3.Items.Add(lName.ToUpper())' 转换为上限
结束 如果
结束 Sub
Best问候
Muthuraja
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
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
这篇关于ListBox程序传输名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!