vb从listbox读取数据

vb从listbox读取数据,把类似于122.226.194.170administrator123右击菜单把那一行的ip用户名密码赋值给变量overipoveruser... vb从listbox读取数据,把类似于122.226.194.170 administrator 123
右击菜单把那一行的ip 用户名 密码 赋值给变量overip overuser overpass
展开
 我来答
百度网友27862d5
2009-12-13 · TA获得超过785个赞
知道大有可为答主
回答量:387
采纳率:50%
帮助的人:427万
展开全部
Option Explicit
Dim IP() As String, Admin() As String, Pass() As String
Private Sub Command1_Click()
Dim IPS() As String, j%, I%
Dim IPADPAS As String, AdminPass() As String
I = GetTxtCount(App.Path & "\IP.txt")
ReDim IP(1 To I), Admin(1 To I), Pass(1 To I)
Open App.Path & "\IP.txt" For Input As #1
Do While Not EOF(1)
j = j + 1
Line Input #1, IPADPAS
If IPADPAS <> "" Then
IPS = Split(IPADPAS, ":")
IP(j) = Right((Left(IPS(0), Len(IPS(0)) - 1)), Len(IPS(0)) - 2)
AdminPass = Split(Trim(IPS(1)), " ")
Admin(j) = AdminPass(0)
Pass(j) = IIf(Left(AdminPass(1), 1) = "[", "", AdminPass(1))
End If
Loop
Close #1
For I = 1 To I
List1.AddItem IP(I) & "," & Admin(I) & "," & Pass(I)
Next I
End Sub

Private Function GetTxtCount(sPath As String) As Long
Dim I As Long, V As String
Open sPath For Input As #1
While Not EOF(1)
Line Input #1, V
If V <> "" Then I = I + 1
Wend
Close #1
GetTxtCount = I
End Function

Private Sub LetVal_Click()
Dim overip As String, overuser As String, overpass As String
overip = IP(List1.ListIndex + 1)
overuser = Admin(List1.ListIndex + 1)
overpass = Pass(List1.ListIndex + 1)
Text1 = overip
Text2 = overuser
Text3 = overpass
End Sub

Private Sub List1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 2 Then PopupMenu Me.Menu
End Sub
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式