[VB.NET]How to make a login system with register[VB.NET]

Was this tutorial good?

  • Yes

    Votes: 5 38.5%
  • No

    Votes: 8 61.5%

  • Total voters
    13
Newbie Spellweaver
Joined
Apr 10, 2007
Messages
22
Reaction score
0
Hi, today i gonna do something that no one have done at ragezone yet i think :) I will teach you how to make a login system with included register. We will use windows forms and modules.

Language: VB.NET
Application: Visual Basic 2005 Express Edition[Works with 2008]
Tested with VB 2005 EE, TESTED AND WORKING!
All code by me!
-----------------------------------

1. Open Visual Basic.
2. Choose Windows Application & click OK!

3. Resize your form, add 1tabcontrol, 2buttons, 2textboxes.

4. Click at tabcontrol1 and click the properties called TabPages and name the first one to Login and the second one to Register.

Also add a new form!!!!!

5. Copy everything from TabPage Login to TabPage Register,
Change the text at first button to Register.

6. Double click My Project in Solution Explorer.

7. Click Settings, add a 10 settings as i show
User1
Pass1
User2
Pass2
User3
Pass3
User4
Pass4
User5
Pass5
User6
Pass6
User7
Pass7
User8
Pass8
User9
Pass9
User10
Pass10

8. Now add a module and name it modRegister, in the module type in this code:
Public Sub userReg()
If My.Settings.User1 = "" And My.Settings.Pass1 = "" Then
My.Settings.User1 = Form1.txtregUser.Text
My.Settings.Pass1 = Form1.txtregPass.Text
ElseIf My.Settings.User2 = "" And My.Settings.Pass2 = "" Then
My.Settings.User2 = Form1.txtregUser.Text
My.Settings.Pass2 = Form1.txtregPass.Text
ElseIf My.Settings.User3 = "" And My.Settings.Pass3 = "" Then
My.Settings.User3 = Form1.txtregUser.Text
My.Settings.Pass3 = Form1.txtregPass.Text
ElseIf My.Settings.User4 = "" And My.Settings.Pass4 = "" Then
My.Settings.User4 = Form1.txtregUser.Text
My.Settings.Pass4 = Form1.txtregPass.Text
ElseIf My.Settings.User5 = "" And My.Settings.Pass5 = "" Then
My.Settings.User5 = Form1.txtregUser.Text
My.Settings.Pass5 = Form1.txtregPass.Text
ElseIf My.Settings.User6 = "" And My.Settings.Pass6 = "" Then
My.Settings.User6 = Form1.txtregUser.Text
My.Settings.Pass6 = Form1.txtregPass.Text
ElseIf My.Settings.User7 = "" And My.Settings.Pass7 = "" Then
My.Settings.User7 = Form1.txtregUser.Text
My.Settings.Pass7 = Form1.txtregPass.Text
ElseIf My.Settings.User8 = "" And My.Settings.Pass8 = "" Then
My.Settings.User8 = Form1.txtregUser.Text
My.Settings.Pass8 = Form1.txtregPass.Text
ElseIf My.Settings.User9 = "" And My.Settings.Pass9 = "" Then
My.Settings.User9 = Form1.txtregUser.Text
My.Settings.Pass9 = Form1.txtregPass.Text
ElseIf My.Settings.User10 = "" And My.Settings.Pass10 = "" Then
My.Settings.User10 = Form1.txtregUser.Text
My.Settings.Pass10 = Form1.txtregPass.Text
End If
My.Settings.Save()
End Sub

9. Add this code to the same module also:
Public Sub userLogin()
If Form1.txtUser.Text = My.Settings.User1 And Form1.txtPass.Text = My.Settings.Pass1 Then
Form2.Show()
ElseIf Form1.txtUser.Text = My.Settings.User2 And Form1.txtPass.Text = My.Settings.Pass2 Then
Form2.Show()
ElseIf Form1.txtUser.Text = My.Settings.User3 And Form1.txtPass.Text = My.Settings.Pass3 Then
Form2.Show()
ElseIf Form1.txtUser.Text = My.Settings.User4 And Form1.txtPass.Text = My.Settings.Pass4 Then
Form2.Show()
ElseIf Form1.txtUser.Text = My.Settings.User5 And Form1.txtPass.Text = My.Settings.Pass5 Then
Form2.Show()
ElseIf Form1.txtUser.Text = My.Settings.User6 And Form1.txtPass.Text = My.Settings.Pass6 Then
Form2.Show()
ElseIf Form1.txtUser.Text = My.Settings.User7 And Form1.txtPass.Text = My.Settings.Pass7 Then
Form2.Show()
ElseIf Form1.txtUser.Text = My.Settings.User8 And Form1.txtPass.Text = My.Settings.Pass8 Then
Form2.Show()
ElseIf Form1.txtUser.Text = My.Settings.User9 And Form1.txtPass.Text = My.Settings.Pass9 Then
Form2.Show()
ElseIf Form1.txtUser.Text = My.Settings.User10 And Form1.txtPass.Text = My.Settings.Pass10 Then
Form2.Show()
Else
MsgBox("Invalid login information!", title:="Invalid Information!")
End If
End Sub

10. Now go to your form1 and double click Login button and type in this code:
Call userLogin

11. Now double click the Register button and type in this code:
Call userReg
 
Please use constructive criticism.
 
i think the easy'st way is with

Code:
GetPrivateProfileString
WritePrivateProfileString
just learn vb basic and creat somethink like this,

Code:
Dim Username01 As String
Dim Password01 As String
Dim Way As Long

Username01 = Space(MaxLen)
Password01 = Space(MaxLen)

        Way = GetPrivateProfileString("Login", "Username01", "", Username01, MaxLen, "\login.ini")
        Username01 = Mid$(Username01, 1, Ret)
        Way = GetPrivateProfileString("Login", "Password01", "", Password01, MaxLen, "\login.ini")
        Password01 = Mid$(Password01, 1, Ret)

If Textbox1.text = Username01 and Textbox02.text = Password01 then Form2.show()
else
MsgBox("Incorrect Login", msgBoxStyle.Critical.Critical, "Error")
end if
but you need to get a FTP server and change the "/login.ini" ...

add one "Microsoft Internet Transfer Control" then put this in the "/login.ini"

Code:
        Way = GetPrivateProfileString("Login", "Username01", "", Username01, MaxLen, AxInet1.OpeUrl("www.Domaind.com/Accounts/Login.ini") , datatype:=false ))

...

        Way = GetPrivateProfileString("Login", "Password01", "", Password01, MaxLen, AxInet1.OpeUrl("www.Domaind.com/Accounts/Login.ini") , datatype:=false ))
then the Login.ini need to look so

Code:
[Login]
Username01=Momo
Password01=Animix
hope u understand it ...
 
Back