Login on VB

Blaze2002

New Member
Joined
Mar 2, 2004
Messages
13
Hiya evry1! rite i have a form in visual basics that i want to protect using a login thingie! i have 3 codes that work fine together:
Public declorations:

Dim x As String
Dim y As String
Dim loginsucceeded As Boolean

Cancel button:

Private Sub CommandButton1_Click()
If MsgBox(" Are you sure you want to cancel log in?", vbYesNo) = vbYes Then
End
End If
End Sub

and the login section:

Private Sub CommandButton2_Click()
x = "user"
y = "admin"
If txtpassword = y And txtusername = y Then
FRMwk1.Show
loginsucceeded = True
Unload Me
Else
If txtpassword = x And txtusername = x Then
FRMwk1.Show
loginsucceeded = True
Unload Me
Else
If loginsucceeded = False Then
MsgBox ("Please enter correct name and password")
End If
End If
End If
End Sub

This all works fine till i want to put in a password and username! :oops: where in the code can i tell VB what the password and username is and when i type it in how can i get it to show "******" instead of the letters??
:rolleyes:
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Make a textbox on the userform. Look in the properties window for the PasswordChar field. Put a "*" in there with no quotes or whatever symbol you want to use.

Then try something like this

Dim MyPassword as String

MyPassword = "Admin123"


Then later on after the input say

If TextBox1.Value = MyPassword then

msgbox("Access Granted")

else

msgbox("Access Denied")

end if
 
Upvote 0
Blaze, DRJ speaks the truth. Let's go through it:

You have a userform with 2 textboxes and 2 commandbuttons?

The textboxes are named: txtpassword and txtusername?

The commandbuttons are named: CommandButton1 and CommandButton2?

You have masked each textbox using DRJ's advice above?

The way your code is written you need to either type "user" or "admin" in both textboxes to gain access.
 
Upvote 0
yes i know! but it just wont do it! ive tried wot he said and what you said but with no luck! :(
 
Upvote 0
Did you put the code supplied by DRJ in the txtpassword_change procedure??

if so then you need to move it to on of the command buttons (The one you have to press to login)
 
Upvote 0

Forum statistics

Threads
1,213,526
Messages
6,114,122
Members
448,550
Latest member
CAT RG

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top