VBScript equals problems

百般思念 提交于 2019-12-24 19:53:09

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!