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

来源:百度知道 编辑:UC知道 时间:2024/06/22 17:26:05
比如我新建个窗体
上面放个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呢?

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

验证码?
form_load()
dim s as string
s=filec.openfile("d:\1.txt")
if text1.text=s then
msgbox "成功
else
msgbox "失败
endif
end sub

‘先读入:
dim a as string
a = "d:/1.txt"
if text1.text like a then
msgbox"成功"
else
msgbox“失败”

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

Sub Command1_Click()
Dim s As String
Dim s1 As String

Open "d:\1.txt"