VB读取记事本指定信息

C盘里有一个2.txt的记事本,里面内容是:
Physical Address. . . . . . . . . : 00-E0-A0-0B-6D-2B
Dhcp Enabled. . . . . . . . . . . : No
IP Address. . . . . . . . . . . . : 192.168.1.254
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.1.1
DNS Servers . . . . . . . . . . . : 192.168.1.1
然后VB窗体里有二个控件,一个是Label1,一个是Command1,当按一
下Command1时候,Label1要显示记事本里“192.168.1.254”
谢谢!VB读取记事本代码

Private Sub Command1_Click()
Dim s As String
Open "C:\1.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, s
If UCase(Left(s, 2)) = "IP" Then
Label1.Caption = Split(s, ":")(1)
Exit Do
End If
Loop
Close #1
End Sub
温馨提示:答案为网友推荐,仅供参考
第1个回答  2008-06-17
Private Sub Command1_Click()
Open "c:\2.txt" For Input As #1
Do
Input #1, s, s1, x
If s & " " & s1 = "IP Address" Then
Label1 = x
Close #1
Exit Sub
End If
Close #1
MsgBox "没有找到"
End Sub
相似回答