0

所以我一直在 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 加载用户名信息?

4

1 回答 1

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

希望这会有所帮助,您可以改进它!

于 2013-06-18T04:17:34.380 回答