在线等,VB与文本文档问题。

比如我新建个窗体
上面放个Text控件和按钮一个
要实现:
在Text中输入一句话
要是和D:/1.txt的内容一样,弹出对话框“成功”,否则“错误”
1.2楼不行 4楼太长
3楼可以,不知道可以
解释下代码么?
daofuuq 你能解释一下
Dim a As String
Open "d:/1.txt" For Input As #1
Input #1, a
Close #1
我可以全局定义吗?还是必须在Private Sub Command1_Click()下dim呢?

第1个回答  2009-08-08
Sub Command1_Click()
Dim s As String
Dim s1 As String

Open "d:\1.txt" For Input As #1
If Not EOF(1) Then
Line Input #1, s
While Not EOF(1)
s = s & vbCrLf
Line Input #1, s1
s = s & s1
Wend
End If

Close #1

If text1.Text = s Then
MsgBox "成功"
Else
MsgBox "错误"
End If

End Sub
第2个回答  2009-08-08
验证码?
form_load()
dim s as string
s=filec.openfile("d:\1.txt")
if text1.text=s then
msgbox "成功
else
msgbox "失败
endif
end sub
第3个回答  2009-08-08
2楼不行的吧
Private Sub Command1_Click()
Dim a As String
Open "d:/1.txt" For Input As #1
Input #1, a
Close #1
If Text1.Text Like a Then
MsgBox "成功"
Else
MsgBox "失败"
End If
End Sub
第4个回答  2009-08-08
‘先读入:
dim a as string
a = "d:/1.txt"
if text1.text like a then
msgbox"成功"
else
msgbox“失败”
第5个回答  2009-08-08
lngHandle = FreeFile()
Open "d:\1.txt" For Input As lngHandle
Line Input #lngHandle, strline
close #lnghandle
if text1.text=strline then
msgbox "成功"
else
msgbox "失败"
end if本回答被提问者采纳
相似回答
大家正在搜