Results 1 to 8 of 8

Thread: Password Help.

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2001
    Location
    Northern Ireland
    Posts
    17

    Unhappy

    Hi! Folks,

    As I am new to VbEnterprize I would be greatful for some help with the following:
    Password.

    Private Sub cmdEnter_Click()
    Dim password As String
    password = "123"

    If txtPassword.Text = password Then
    frmServices.Show
    End If
    If txtPassword.Text <> password Then
    MsgBox ("Wrong Password. Please Try again"), vbRetryCancel
    End If
    txtPassword.Text = ""

    End Sub

    I would like password as Integer and not string so I can use numbers only in the password.

    Enter:

    cmdEnter_Click()
    What code do I need to use to enter the password using the return Key also.

    Many thanks.
    Bill

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Code:
    Private Sub cmdEnter_Click() 
    Dim password As Integer
    password = 123
    
    If Val(txtPassword.Text) = password Then 
      frmServices.Show 
    ElseIf txtPassword.Text <> password Then 
      MsgBox ("Wrong Password. Please Try again"), vbRetryCancel 
    End If 
    
    txtPassword.Text = "" 
    
    End Sub 
    
    Private Sub txtPassword_KeyPress(KeyAscii AS Integer)
      If Not IsNumeric(Chr(KeyAscii)) Then
        KeyAscii = 0
      End If
    End Sub
    As for the return key, set the Default property of cmdEnter to True and it will work...
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Feb 2001
    Location
    Northern Ireland
    Posts
    17

    Wink Password help

    crptcblade,


    Many Thanks.
    Bill

  4. #4
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    no prob
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Feb 2001
    Location
    Northern Ireland
    Posts
    17

    Password help

    crptcblade,

    Sorry to be a pain,
    I wrote the code and It worked with the password 123

    when anyother key is entered as a,b,c,d etc I get the following error.

    ElseIf txtPassword.Text <> password Then

    Cheers
    Bill

  6. #6
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Code:
    Private Sub txtPassword_KeyPress(KeyAscii AS Integer)
      If Not IsNumeric(Chr(KeyAscii)) Then
        KeyAscii = 0
      End If
    End Sub
    this code shouldn't allow you to put in anything but numbers, but try changing :

    ElseIf txtPassword.Text <> password Then

    to :

    ElseIf Val(txtPassword.Text) <> password Then

    or just plain "Else"
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  7. #7
    Junior Member random150's Avatar
    Join Date
    Mar 2001
    Location
    USA
    Posts
    30
    this will stop it from haveing an error

    Code:
    Private Sub cmdEnter_Click() 
    
    If CInt(Val( _
    	txtPassword.Text)) = 123 Then  _
    	
    frmServices.Show 
    Else
    MsgBox ("Wrong Password. Please Try again"), vbRetryCancel 
    End If 
    
    
    End Sub 
    
    Private Sub Text1_KeyDown(KeyCode As Integer, Shift  _
    	As Integer)
    
    If keycode= 13 Then debug.Print  _
    	"ENTER"'this is to check for enter
    End Sub''cmdEnter_Click()

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Feb 2001
    Location
    Northern Ireland
    Posts
    17

    Password help

    Many thanks
    Bill

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width