所以我一直在使用VB.NET中的这个程序来抓取用户Skype信息,例如句柄,生日,电话号码等。但是我找不到将特定用户信息加载到ListBox的方法。这是我的代码
Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click
For Each hmm As SKYPE4COMLib.User In Skype.Friends
ListBox2.Items.Add("<>-----------------------------------------<>")
ListBox2.Items.Add(hmm.FullName)
ListBox2.Items.Add(hmm.Handle)
ListBox2.Items.Add(hmm.Sex)
ListBox2.Items.Add(hmm.PhoneHome + hmm.PhoneMobile + hmm.PhoneOffice)
ListBox2.Items.Add(hmm.Aliases)
ListBox2.Items.Add(hmm.Birthday)
ListBox2.Items.Add(hmm.City)
ListBox2.Items.Add(hmm.Country)
ListBox2.Items.Add(hmm.Language)
ListBox2.Items.Add(("Friends: ") & hmm.NumberOfAuthBuddies)
ListBox2.Items.Add("<>-----------------------------------------<>")
Next
End Sub
唯一的问题是,当我点击Button8时,它会将我的所有联系人信息加载到ListBox中,我只想在TextBox3中加载用户名的信息。
这是一个视觉:
图片中的TextBox是TextBox3,文本“Get”的按钮是Button8,ListBox是ListBox2。如何让ListBox2从TextBox3加载用户名的信息?
答案 0 :(得分:0)
你可以这样做..但不要排序ListBox2 !!
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim lstHandle as New List(Of String)
Dim lstSex as New List(Of String)
Dim lstPhone as New List(Of String)
Dim lstAlias as New List(Of String)
Dim lstBDay as New List(Of String) '--> you can change to date
Dim lstCity as New List(Of String)
Dim lstCountry as New List(Of String)
Dim lstLang as New List(Of String)
Dim lstFriend as New List(Of String) '--> you can to integer
For Each hmm As SKYPE4COMLib.User In Skype.Friends
'ListBox2.Items.Add("<>-----------------------------------------<>")
ListBox2.Items.Add(hmm.FullName)
lstHandle.Add(hmm.Handle)
lstSex.Add(hmm.Sex)
lstPhone.Add(hmm.PhoneHome + hmm.PhoneMobile + hmm.PhoneOffice)
lstAlias.Add(hmm.Aliases)
lstBDay.Add(hmm.Birthday)
lstCity.Add(hmm.City)
lstCountry.Add(hmm.Country)
lstLang.Add(hmm.Language)
lstFriend.Add(("Friends: ") & hmm.NumberOfAuthBuddies)
'ListBox2.Items.Add("<>-----------------------------------------<>")
Next
End Sub
Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click
Dim x as Integer = ListBox2.FindStringExact(TextBox3.Text)
If x > -1 then
Msgbox( _
ListBox2.Items.item(x) & vbCrLf & _
lstHandle(x) & vbCrLf & _
lstSex(x) & vbCrLf & _
lstPhone(x) & vbCrLf & _
lstAlias(x) & vbCrLf & _
lstBDay(x) & vbCrLf & _
lstCity(x) & vbCrLf & _
lstCountry(x) & vbCrLf & _
lstLang(x) & vbCrLf & _
lstFriend(x))
Endif
End Sub
希望这会有所帮助,你可以改进它!