How to make a Login using WebClient/Vb

AAW May 20, 2014

  1. AAW

    AAW Developer XPG Developer Lifetime Gold
    85/94

    Joined:
    Aug 6, 2012
    Messages:
    652
    Likes Received:
    690
    Trophy Points:
    85
    Gender:
    Male
    Location:
    Inside XPG
    Console:
    Xbox
    How to make a Login using WebClient/Vb

    Step 1
    Create a new project
    [​IMG]
    Step 2
    Add the following items below
    • 2 Labels (Username, Password)
    • 2 Textbox's (Username, Password)
    • 1 Checkbox (Remember Login)
    • 2 Buttons (Login, Cancel)
    It should look like this
    [​IMG]

    Step 3

    You now need to upload a file to a webhost or you could use dropbox

    Filename: login.php or login.html

    Once you've created the file, edit it and add 1 or 2 accounts in the format below



    Code:
    Username | Password
    This is case sensitive.

    Step 4

    Double like on the Login Button & add the code below

    Code:
    Dim userinfo As String = New System.Net.WebClient().DownloadString("Your Website Here")
            If TextBox1.Text = "" AndAlso TextBox2.Text = "" Then
                MessageBox.Show("No Username or Password has been entered!", "Login Form", MessageBoxButtons.OK, MessageBoxIcon.Error)
            ElseIf userinfo.Contains(TextBox1.Text + " | " + TextBox2.Text) Then
                Me.Hide()
                MessageBox.Show("Username: " & TextBox1.Text)
            Else
                MessageBox.Show("Invalid Credentials!", "Login Form", MessageBoxButtons.OK, MessageBoxIcon.Error)
            End If

    Step 5

    Double click on the Cancel Button and add the code below
    Code:
    Application.exit
    Step 6

    Click on Project > Project Name Properties.... > Settings

    Now add 2 Settings - 1 Username & 1 Password
    Put the type too "system.collections.specialized.stringcollection"
    For the value click the 3 dots and type "google.com" and then ok!
    Open it back on and remove "google.com" the value should now be XML

    Step 7

    Double click on "Remember Login" and Put the following code
    Code:
    If CheckBox1.Checked = True Then
                My.Settings.Username.Add(TextBox1.Text)
                My.Settings.Password.Add(TextBox2.Text)
                My.Settings.Save()
            End If
    Step 8

    Build the form and test your program, by the way, its case sensitive!

    [hr]

    Thanks

    AAW
     

Share This Page

Close