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

2025-01-25 01:28:05
推荐回答(2个)
回答1:

'替换这个函数看看:
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

回答2:

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