问题
I have been working on a vbs login and signup program I have a fully functional working signup program but I am having troubles seeing if a inputbox a.k.a the password is equal to the logged password from signup in a file
uname = inputbox("Please type your Username.")
pword = inputbox("Please ebter your Password.")
Set objFileToRead = CreateObject("Scripting.FileSystemObject").OpenTextFile(uname + ".txt",1)
strFileText = objFileToRead.ReadLine()
objFileToRead.Close
Set objFileToRead = Nothing
If strFileToRead = pword Then
document.write("Welcome!")
CreateObject("WScript.Shell").Run "forums.htm"
Else
msgbox("Incorrect Username or Password")
Wscript.Quit
End If
回答1:
Use "Option Explicit". Then blunders like
strFileText = objFileToRead.ReadLine()
vs.
If strFileToRead = pword Then
(strFileText <> strFileToRead)
will be caught.
来源:https://stackoverflow.com/questions/18552397/vbscript-equals-problems