VB程序设置密码

来源:百度知道 编辑:UC知道 时间:2024/05/31 06:35:11
比如,C盘有一个1.txt,内容为123,如何验证在text1中入的内容是否与1.txt中的内容一致?如果一致则运行abc.exe,如果不一致则msgbox"错误"。

Private Sub Command1_Click()
.
.
.
.
.
.
End Sub

Private Sub Command1_Click()
dim fso as new filesystemobject
dim fst as textstream
dim temstr as string

set fst=fso.opentextfile("c:\1.txt",forreading)
temstr=fst.readline
'上面是读取一行内容,你可以循环语句全读出来
if temstr=text1.text then shell ("c:\abc.exe"):goto e
msgbox "错误"

e:

End Sub