[VB6] Check Logout Function

Discussion in 'Code Snippets and Tutorials' started by ricky92, Feb 23, 2007.

  1. ricky92

    ricky92 Administrator
    Staff Member

    Joined:
    Nov 10, 2006
    Messages:
    1,866
    Likes Received:
    67
    This is a function I made for those who don't want to waste time on making it...

    It returns, as a string:
    - "bad password" if the password has changed
    - "account frozen" if the account has been frozen
    - "logged in" if everything went ok
    - "error" if an error occurs

    It can also be used as a NeoLogin function...

    Here is it:
    Code (Visual Basic):
    1. <div class="vb" id="{CB}" style="font-family: monospace;"><ol><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"><span style="color: #b1b100;">Public</span> <span style="color: #b1b100;">Function</span> CheckLogout<span style="color: #66cc66;">(</span>Username <span style="color: #b1b100;">As</span> TextBox, Password <span style="color: #b1b100;">As</span> TextBox, Wrapper <span style="color: #b1b100;">As</span> Object<span style="color: #66cc66;">)</span> <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">String</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"><span style="color: #b1b100;">Dim</span> strCheck <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">String</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"><span style="color: #b1b100;">Dim</span> strLogin <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">String</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp; &nbsp; strCheck = Wrapper.<span style="color: #66cc66;">GetWrapper</span><span style="color: #66cc66;">(</span><span style="color: #ff0000;">"http://www.neopets.com/neomessages.phtml"</span><span style="color: #66cc66;">)</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp; &nbsp; <span style="color: #b1b100;">If</span> <span style="color: #b1b100;">InStr</span><span style="color: #66cc66;">(</span><span style="color: #cc66cc;">1</span>, strCheck, <span style="color: #ff0000;">"http://images.neopets.com/images/signup/aisha_signup.gif"</span><span style="color: #66cc66;">)</span> <span style="color: #b1b100;">Then</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; w.<span style="color: #66cc66;">Postwrapper</span> <span style="color: #ff0000;">"http://www.neopets.com/hi.phtml"</span>, <span style="color: #ff0000;">"destination=%2Fpetcentral.phtml&username="</span> & Username.<span style="color: #66cc66;">Text</span>, <span style="color: #ff0000;">"http://www.neopets.com/loginpage.phtml"</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strLogin = w.<span style="color: #66cc66;">Postwrapper</span><span style="color: #66cc66;">(</span><span style="color: #ff0000;">"http://neopets.com/login.phtml"</span>, <span style="color: #ff0000;">"username="</span> & Username.<span style="color: #66cc66;">Text</span> & <span style="color: #ff0000;">"&password="</span> & Password.<span style="color: #66cc66;">Text</span> & <span style="color: #ff0000;">"&destination=%2Fpetcentral.phtml"</span>, <span style="color: #ff0000;">"http://neopets.com/hi.phtml"</span><span style="color: #66cc66;">)</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">If</span> <span style="color: #b1b100;">InStr</span><span style="color: #66cc66;">(</span><span style="color: #cc66cc;">1</span>, strLogin, <span style="color: #ff0000;">"badpassword"</span><span style="color: #66cc66;">)</span> <span style="color: #b1b100;">Then</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CheckLogout = <span style="color: #ff0000;">"bad password"</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">MsgBox</span> <span style="color: #ff0000;">"The program tried to login again, but"</span> & <span style="color: #b1b100;">vbCr</span> & <span style="color: #ff0000;">"the password doesn't work anymore"</span>, <span style="color: #b1b100;">vbOKOnly</span> + <span style="color: #b1b100;">vbCritical</span>, <span style="color: #ff0000;">"Error"</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">Exit</span> <span style="color: #b1b100;">Function</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">ElseIf</span> <span style="color: #b1b100;">InStr</span><span style="color: #66cc66;">(</span><span style="color: #cc66cc;">1</span>, strLogin, <span style="color: #ff0000;">"This account has been"</span><span style="color: #66cc66;">)</span> <span style="color: #b1b100;">Then</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CheckLogout = <span style="color: #ff0000;">"account frozen"</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">MsgBox</span> <span style="color: #ff0000;">"The account "</span> & Username & <span style="color: #ff0000;">" has been frozen!!!"</span>, <span style="color: #b1b100;">vbCritical</span>, <span style="color: #ff0000;">"Frozen!"</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">Exit</span> <span style="color: #b1b100;">Function</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">ElseIf</span> <span style="color: #b1b100;">InStr</span><span style="color: #66cc66;">(</span><span style="color: #cc66cc;">1</span>, strLogin, <span style="color: #ff0000;">"petcentral"</span><span style="color: #66cc66;">)</span> <span style="color: #b1b100;">Then</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CheckLogout = <span style="color: #ff0000;">"logged in"</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">Else</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CheckLogout = <span style="color: #ff0000;">"error"</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">End</span> <span style="color: #b1b100;">If</span></li><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">&nbsp; &nbsp; <span style="color: #b1b100;">End</span> <span style="color: #b1b100;">If</span></li><li style="padding: 0 5px; background-color: #f9f9f9; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;"><span style="color: #b1b100;">End</span> <span style="color: #b1b100;">Function</span></li></ol></div>
    It uses textboxes, they could be annoying if someone wants to leave the program running for hours... (they stop the thread)
     
  2. Anonymous

    Anonymous Guest

    So to use it you just do this?
    Code (Text):
    1.  call CheckLogout
    +rep
     
  3. ricky92

    ricky92 Administrator
    Staff Member

    Joined:
    Nov 10, 2006
    Messages:
    1,866
    Likes Received:
    67
    No, just

    Code (Text):
    1. CheckLogout(Username As TextBox, Password As TextBox, Wrapper As Object)
    for example:

    strCheck = CheckLogout(txtUsername, txtPassword, HTTPWrapper1)
     
  4. Anonymous

    Anonymous Guest

    oh, ok thanks.
     
  5. moose

    moose Level IV

    Joined:
    Jan 20, 2007
    Messages:
    934
    Likes Received:
    0
    wow... is this ever confusling