vb 读取文本内容,与文本框内容进行比较,明明内容是一样,但比较结果为不一样

来源:百度知道 编辑:UC知道 时间:2024/06/02 06:44:21
vb 读取文本内容,与文本框内容进行比较,明明内容是一样,但比较结果为不一样
新建工程
在FORM1 中 添加六个按钮,一个LABEL
新建一个FORM2窗体, 添加一个LABEL,一个文本框,一个按钮
再新建一个FORM3窗体, 添加两个LABEL,两个文本框,一个按钮
具体代码如下:
form1:Public pw As String

Private Sub Command1_Click()

Shell "cmd /k shutdown -s -t 1800 -c 游戏时间到了 ", vbHide

isclose = 0

End Sub

Private Sub Command2_Click()

Shell "cmd /k shutdown -s -t 3600 -c 游戏时间到了 ", vbHide

isclose = 0

End Sub

Private Sub Command3_Click()

Shell "cmd /k shutdown -s -t 7200 -c 游戏时间到了 ", vbHide

isclose = 0

End Sub

Private Sub Command4_Click()

Shell "cmd /k shutdown -s -t 10800 -c 游戏时间到了 ", vbHide

isclose = 0

End Sub

Private Sub Command5_Click()

Form2.Show

End Sub

Private Sub Command6_Click()

Form3.Show

End Sub

'替换这个函数看看:
Public Function openfile(ByVal filepath As String) As String '读入文件函数

Dim data As String
Open filepath For Input As #1

While Not EOF(1)

Line Input #1, sline
data = data & sline & vbNewLine'你忽略了最后1个换行符

Wend

Close #1

openfile = Left(data, Len(data) - Len(vbNewLine))'去掉被你忽略的换行符

End Function

这样看看:
MsgBox "-" & Trim(Text1.Text) & "-" & vbCrLf & _
"-" & Trim(Form1.pw) & "-"