Jump to content
xisto Community
Sign in to follow this  
kitty

Simple Login In Visual Basic 6 user interaction example trough login programm

Recommended Posts

Correction in code...Simple Login In Visual Basic 6

Dim I As Integer 'For the For Next LoopFor I = 1 To TotUser 'Check every user.If (Saved_Name(I) = MyUName) And (Saved_Pass(I) = MyPass) ThenMsgBox "Good day " & MyName & "." & vbCrLf & "WelcomeTo our program, we wish You pleasant work.", vbInformation + vbOKOnly,"Welcome"Exit sub 'You are logged in!ElseIf I = TotUser Then MsgBox "We are sorry, username and/or password are not correct", vbCritical + vbOKOnly, "Error" EndEnd IfEnd IfNext I

 

the red part is the corrected code... Enjoy & thanks for this posting...

-reply by Prashant

Share this post


Link to post
Share on other sites
codes and procedure on how to design a time table schedule system using visual basic 6.0?Simple Login In Visual Basic 6

hello,

 Based on the project am having on hand, I would need every steps taken to

design this time table for my school.So I would be grateful if every required information is been sent to my mail.

 

 

-reply by boniface ishong Morphy

Share this post


Link to post
Share on other sites

You forgot to say to type in the label and text boxes? and you have a lot of end if but no starting if's?for the password make a label and text box, then click on that text box and input password code in it, and the same for username, and full name codes?I am new to this too, but there must be some box? for users to input in? I am lost on this tut?I get a bunch of errors just typing it in the way you said to?and what about setting up license keys for users? and making this script work with a actual live website?do you use the same variables as the vb script does? how does vb script software and actual live websitesknow that a user has a key and signed up correctly to a website through a vb script software?if anyone can figure this out?

Share this post


Link to post
Share on other sites

You forgot to say to type in the label and text boxes? and you have a lot of end if but no starting if's?

 

for the password make a label and text box, then click on that text box and input password code in it, and

the same for username, and full name codes?

 

I am new to this too, but there must be some box? for users to input in? I am lost on this tut?

 

I get a bunch of errors just typing it in the way you said to?

 

and what about setting up license keys for users? and making this script work with a actual live website?

 

do you use the same variables as the vb script does? how does vb script software and actual live websites

know that a user has a key and signed up correctly to a website through a vb script software?

 

if anyone can figure this out?

 

 

 

 

First of all, I am NOT a programmer, this is something my friend taught me. It describes basic interaction with the user, while showing basic functionality of this simple programm. So, without further ado, we're off to the tutorial:

 

First of all, start your visual basic, when prompted for new project, select Standard Exe. Next, we need to open code window, so we can start typing the program. This can be done in two ways, one is double clicking on the form, or selecting Code from View menu.

 

If you double clicked on the form, you will see following text:

Private Sub Form_Load()End Sub
If you don't see it, you will need to type it by hand. You will only need to type the first line (Private Sub Form_Load()), the last line, visual basic will add automaticaly (End Sub).

 

Next, we need to declare variables we will use in our program. Here's the next piece of code:

Dim MyName As String ' This variable contains users full nameDim MyUName As String ' This variable contains users login name (username)Dim MyPass As String ' This variable contains users passwordDim Response As Integer ' This variable contains users answers from message boxesDim Saved_Name As String ' This variable contains saved username from fileDim Saved_Pass As String 'This variable contains saved password from file
This part is simple, we only prepare variables for use (I know there is more technical explanation for this, but I can't remember :P).

 

Now, we need to read username and password from the file. Now, for this example, we will use simple text file. You can create it using notepad (I don't think you need a tutorial on that :(). In that file, write the username you want, and in next line, write the password. Now, add the following code:

Open "pass.txt" For Input As #1 'we open file with data we need  Line Input #1, Saved_Name ' We read username from file  Line Input #1, Saved_Pass 'We read password from fileClose #1 'we close the file

Now that we have done this, we can proceed with basic interaction with the user:

Login_Name:MyName = InputBox("Please, enter Your name.", "Introduce yourself", "")If MyName = "" Then  Response = MsgBox("To continue with the program, You need to introduce Yourself." & vbCrLf & "Do You wish to proceed with the programm?", vbCritical + vbYesNo, "Error")  If Response = vbYes Then GoTo Login_Name  If Response = vbNo Then    MsgBox "We are sorry You do not wish to proceed." & vbCrLf & "We wish You a good day", vbInformation + vbOKOnly, "End"    End  End IfEnd If
First, we ask a user, to enter his full name, so we can know how to address him/her. If the user doesn't enter his/hers name, we will tell him he/she needs to enter it, or to quit the program. I believe the code is very self explainatory.

 

Next, we will prompt for user name. This is the information that we need for successfull login.

Login_UName:MyUName = InputBox("Good day " & MojeIme & ", please, enter Your user name.", "Login", "")If MyUName = "" Then  Response = MsgBox("To continue with the program, You need to enter username." & vbCrLf & "Do You wish to proceed with the programm?", vbCritical + vbYesNo, "Error")  If Response = vbYes Then GoTo Login_UName  If Response = vbNo Then    MsgBox "We are sorry You do not wish to proceed." & vbCrLf & "We wish You a good day", vbInformation + vbOKOnly, "End"    End  End IfEnd If
This is basicaly the same thing we used for prompting for full name, just with different variables.

 

Next, we ask the user to enter his/hers password, to authenticate into system:

Login_Pass:MyPass = InputBox("Please, enter a password for user name " & MyUName & ".", "Login", "")If MyPass = "" Then  Response = MsgBox("To continue with the program, You need to enter Your password." & vbCrLf & "Do You wish to proceed with the programm?", vbCritical + vbYesNo, "Error")  If Response = vbYes Then GoTo Login_Pass  If Response = vbNo Then    MsgBox "We are sorry You do not wish to proceed." & vbCrLf & "We wish You a good day", vbInformation + vbOKOnly, "End"    End  End IfEnd If
OK, I guess you noticed this is the same thing I used in two earlier segments of programm. I was told it can be done with functions or subs, but I haven't learned it yet :P I guess I'll post another tutorial when I learn how to do that :(

 

OK, we're almost done. All we have to do is check if username and passwords match, and if that is the case, we can proeed with programm. If not, we tell the user he/she made a mistake, and exit the programm. Here is the programm for that segment:

If (Saved_Name = MyUName) And (Saved_Pass = MyPass) Then  MsgBox "Good day " & MyName & "." & vbCrLf & "Welcome to our programm, we wish You pleasant work.", vbInformation + vbOKOnly, "Welcome"Else  MsgBox "We are sorry, username and/or password are not correct", vbCritical + vbOKOnly, "Error"  EndEnd If
Here, we check if saved username is the one entered, and if the saved password is the one entered. If they match, we allow the user to access the programm, if not, we tell him/her there is an error, and exit the programm.

 

I learned this recently, and I hope I passed that knowledge to some of you..

 


You forgot to say to type in the label and text boxes? and you have a lot of end if but no starting if's?

 

for the password make a label and text box, then click on that text box and input password code in it, and

the same for username, and full name codes?

 

I am new to this too, but there must be some box? for users to input in? I am lost on this tut?

 

I get a bunch of errors just typing it in the way you said to?

 

and what about setting up license keys for users? and making this script work with a actual live website?

 

do you use the same variables as the vb script does? how does vb script software and actual live websites

know that a user has a key and signed up correctly to a website through a vb script software?

 

if anyone can figure this out?

Share this post


Link to post
Share on other sites

i need a income tax form in vb. when we entered any id of a number the entire person data should presentin a form.can any body help me.i need the data in the form of ecelsheets

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.