VB6 Neo Programming Tutorial I: The Basics

Discussion in 'Code Snippets and Tutorials' started by the_skip, Mar 21, 2007.

  1. the_skip

    the_skip Level IV

    Joined:
    Dec 25, 2006
    Messages:
    2,354
    Likes Received:
    1
    Location:
    Indiana
    Source +httpwrapper is here
    VB6 Neo Programming Tutorial I: The Basics
    1. Getting VB6
    First you need vb6. To get it the most common but not legit way is torrents. Once you get vb6 look at some beggining tutorials. I am expecting you to know some vb6 before I teach you the way to program using http wrappers. Porgramin is NOT easy and computers are like a child learning something new you need to tell them everything. You will also need alot of asprin when your program dosn't work out.
    2. Desing the Main Form
    Ok so open up vb6. Put a frame on your form in the top left corner. In the frame put a label and the caption of th label will be username. Then, add a textbox and call it txtusername. Below the label that says username put another label that says "Password". Beside it put a textbox called txtpassword. Below the txtpassword text box put a button which is call cmdlogin. The caption Should be login. Then get an http wrapper here Go back to your vb6 project and click on ctrl+d and wher you put the http wrapper click on it then press on ctrl+d again and slect the stuff module. Press control+d to add the stuff module. Then click on the little form with a pencil on it and add it to your from. That is the http wrapper and call it httpwrapper. This is what your form should look like[​IMG]Note: There will be a grey box where you put your http wrapper.
    3. Codeing your button
    put this code in form 1's code delete EVERY line of code and put this
    Code (Text):
    1. 'Varibles you will need
    2. 'If a varible is to be used in 2 or more sybs or function then make it public
    3.  
    4. Public strhtml As String
    5. Public bollogin As Boolean
    6. Private Sub cmdlogin_Click()
    7. 'Sees if username text box is empty
    8. If Len(txtusername.Text) <= 0 Then
    9. 'If it is empty Then it gives an Error
    10. MsgBox "Please enter a username."
    11. Exit Sub
    12. End If
    13. 'Sees if password is empty
    14. If Len(txtpassword.Text) <= 0 Then
    15. 'if it is it gives an error
    16. MsgBox "Please enter a password"
    17. End If
    18. 'Gets the login function
    19. Call Login(txtusername.Text, txtpassword.Text)
    20. 'If login good
    21. If logintrue = True Then
    22. 'Tells you
    23. MsgBox "Loged In"
    24. 'if bad
    25. Else
    26. 'Tells you
    27. MsgBox "Not Logged In"
    28. End If
    29. End Sub
    30.  
    31. 'Login function
    32. Public Function Login(Username As String, Password As String)
    33. 'This is  the line of code that logs you in
    34. 'The first url is the url to send data to
    35. 'The words between the two url's are the data it is sending
    36. 'The last url is the place that you come from when you actually do it
    37. strhtml = httpwrapper.Postwrapper("http://www.neopets.com/login.phtml", "username=" & Username & "&password=" & Password & "&destination=%2Fpetcentral.phtml", "http://www.neopets.com/hi.phtml")
    38. 'If there was a bad password
    39. If InStr(1, strhtml, "badpassword") <> 0 Then
    40. MsgBox "You entered an invalid username/password combination!" & vbNewLine & "Please try again.", vbCritical, "Login Failure"
    41. 'This boolean tells you if the login was sucessfuly
    42. bollogin = False
    43. 'If you have been iced
    44. ElseIf InStr(1, strhtml, "This account has been") <> 0 Then
    45.         MsgBox "ACCOUNT FROZEN!" & vbNewLine & "Please use another.", vbCritical, "Login Failure"
    46. 'Makes the Login sucsess boolian false meaning the login was bad
    47. bollogin = False
    48. Exit Function
    49.     'If you have tried to guess the passwrod two often
    50.     ElseIf InStr(1, strhtml, "too many times") <> 0 Then
    51.         MsgBox "You have tried to guess the password to many times in the last hour!" & vbNewLine & "Try again later.", vbCritical, "Login Failure"
    52. 'Makes the Login sucsess boolian false meaning the login was bad
    53. logintrue = False
    54. Exit Function
    55.          'Sees if there was a bab url
    56.          ElseIf InStr(1, strhtml, "Error 404 : Missing Page Alert") <> 0 Then
    57.         'Makes the Login sucsess boolian false meaning the login was bad
    58.         logintrue = False
    59.                 Exit Function
    60.         'If none of the errors come up the login is good
    61.         Else
    62.         logintrue = True
    63. End If
    64. End Function
    65.  
    66.  
    And there you go. Your're first self made login.
    Next tutorial: Manipulation of source: The main thing you need to do
    +rep if this helped
    Tutorials done 1/7
    If you get any errors tell me
     
  2. omgcat

    omgcat Level IV

    Joined:
    Jan 31, 2007
    Messages:
    1,137
    Likes Received:
    0
    So.. How can we make a list box, say, "Has logged into account *******" Like some other programs do?


    I am making a Battle dome, and avatar grabber.

    I want to log in using this.

    When it logs in can it add into a text box, Succesfully logged into ******
    Or Failed to log into ***** in the side textbox?
     
  3. Anonymous

    Anonymous Guest

    Code (Text):
    1. list1.additem("[" & Time & "] - Logged into account " & txtUsername.text)
    [/code]
     
  4. the_skip

    the_skip Level IV

    Joined:
    Dec 25, 2006
    Messages:
    2,354
    Likes Received:
    1
    Location:
    Indiana
    this is the first of alot of tutorials I am just starting the next one. Source code mnaullation/crash course
     
  5. test123

    test123 Level IV

    Joined:
    Nov 3, 2006
    Messages:
    935
    Likes Received:
    0
    Location:
    Australia
    hey

    great guide, i used it except that http wrapper link didn't work :(

    oh and btw you might wanna spellcheck a bit too:

    boolian = boolean
    bab = bad
    passwrod = password
    "guess the passwrod two often" = guess the password too often
    sucsess = success
    sucessfuly = successfully
    Varibles = variables
     
  6. the_skip

    the_skip Level IV

    Joined:
    Dec 25, 2006
    Messages:
    2,354
    Likes Received:
    1
    Location:
    Indiana
    spelling was never my strong point :oops:
     
  7. NHStephen

    NHStephen Level IV

    Joined:
    Jan 2, 2007
    Messages:
    1,114
    Likes Received:
    9
    Great i typed everthing but the message box didnt work but its good

    EDIT: got it to work
     
  8. the_skip

    the_skip Level IV

    Joined:
    Dec 25, 2006
    Messages:
    2,354
    Likes Received:
    1
    Location:
    Indiana
    was there no msg box.
     
  9. NHStephen

    NHStephen Level IV

    Joined:
    Jan 2, 2007
    Messages:
    1,114
    Likes Received:
    9
    nah i got it to work

    but Stupid thing doesnt want to work here


    strhtml = httpwrapper.Postwrapper("http://www.Filtered Link - For the safety of our users please do not post direct links to Neopets./login.phtml", "username=" & Username & "&password=" & Password & "&destination=%2Fpetcentral.phtml", "http://www.Filtered Link - For the safety of our users please do not post direct links to Neopets./hi.phtml")
     
  10. the_skip

    the_skip Level IV

    Joined:
    Dec 25, 2006
    Messages:
    2,354
    Likes Received:
    1
    Location:
    Indiana
    remove the filter link part
     
  11. Anonymous

    Anonymous Guest

    you need the .text thingie's after username and password!

    strhtml = httpwrapper.Postwrapper("http://www.Filtered Link - For the safety of our users please do not post direct links to Neopets./login.phtml", "username=" & Username.text & "&password=" & Password.text & "&destination=%2Fpetcentral.phtml", "http://www.Filtered Link - For the safety of our users please do not post direct links to Neopets./hi.phtml")

    try that!
     
  12. the_skip

    the_skip Level IV

    Joined:
    Dec 25, 2006
    Messages:
    2,354
    Likes Received:
    1
    Location:
    Indiana
    well actually that is using a login sub
     
  13. NHStephen

    NHStephen Level IV

    Joined:
    Jan 2, 2007
    Messages:
    1,114
    Likes Received:
    9
    then it wants me to replace it ill try that and try to go around the error

    EDIT: im going to make it on the same thing im just going to make it with out a sub form
     
  14. the_skip

    the_skip Level IV

    Joined:
    Dec 25, 2006
    Messages:
    2,354
    Likes Received:
    1
    Location:
    Indiana
    actually I am going to post the source
    Here
     
  15. NHStephen

    NHStephen Level IV

    Joined:
    Jan 2, 2007
    Messages:
    1,114
    Likes Received:
    9
    mmm ty ill try to use the login code off that

    EDIT: lol i forgot to add the http wrapper oops
     
  16. the_skip

    the_skip Level IV

    Joined:
    Dec 25, 2006
    Messages:
    2,354
    Likes Received:
    1
    Location:
    Indiana
    if you use it in your program +rep apprciated. Later today I will finish up my next tutorial
     
  17. lnconcise

    lnconcise Level III

    Joined:
    Dec 7, 2006
    Messages:
    414
    Likes Received:
    0
    Wow! Thanks!

    I'm very new at this, but that's helping alot.
    So, um...dumb question, what's the purpose of a httpwrapper?
     
  18. the_skip

    the_skip Level IV

    Joined:
    Dec 25, 2006
    Messages:
    2,354
    Likes Received:
    1
    Location:
    Indiana
    It is something that will conect to the site and return the html
     
  19. lnconcise

    lnconcise Level III

    Joined:
    Dec 7, 2006
    Messages:
    414
    Likes Received:
    0
    you know how some programs show you the amount of NP and your active pet when you log in?

    what's the code for that?
     
  20. the_skip

    the_skip Level IV

    Joined:
    Dec 25, 2006
    Messages:
    2,354
    Likes Received:
    1
    Location:
    Indiana
    I have the code for it, It uses the most used function when writing a neopet program getstringbetween but that is not included in vb. I now recomend not to use vb6 but rather vb.net. It is free a little more code but alot easier to look at and debug. I am making a site with .net tutorials and if you want I'll pm you the link when I get done with it