Results 1 to 5 of 5

Thread: Is this code right

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2003
    Location
    toronto
    Posts
    12

    Is this code right

    I'm trying to create a prog. which allows a user to enter username and password within 20 seconds. if username/password is not entered within the time allowed prog should terminate, as well as if pwd/ username not entered corrrectly a message shold pop up. Can some one look at this code and tell me where i'm going wrong.
    thank you.

    Private Sub grp1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles grp1.Enter
    Dim Username As String = New String("mark")
    Dim Password As String = New String("pass")
    Dim intCount As Integer = New Integer()

    End Sub

    Private Sub txtUser_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtUser.TextChanged
    If (txtUser.Text) = "mark" And _
    (txtPass.Text) = "Pass" Then
    MsgBox("Logged in...", MsgBoxStyle.Information, "Logged in...")
    Else
    If Not (txtUser.Text) = "mark" Then
    MsgBox("worng username", MsgBoxStyle.Critical + MsgBoxStyle.OKOnly, "Auth")
    Exit Sub
    Else
    If Not (txtPass.Text) = "pass" Then
    MsgBox("wrong password", MsgBoxStyle.Critical + MsgBoxStyle.OKOnly, "Auth.")
    End If
    End If


    End If
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

    End Sub

    Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
    End
    End Sub

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    You are verifying username and password through keychange event . It's completely wrong . It checks the data entered chr by chr . You can paste your code in a button rather than textboxchange event .

  3. #3

    Thread Starter
    New Member
    Join Date
    Feb 2003
    Location
    toronto
    Posts
    12
    i'm trying to get the user to logon only twice but cant seem to do that cant you guide me a bit on that code

  4. #4
    Hyperactive Member phrozeman's Avatar
    Join Date
    Apr 2000
    Location
    Netherlands
    Posts
    442
    next time u post a code put it between [.vbcode] [/Highlight] tags...

    Without the dot (.)

    btw, thought that i posted an small example somewhere in the VB.Net area, just use search to find it
    Last edited by phrozeman; Feb 17th, 2003 at 03:34 AM.
    There's a certain mystique when I speak, that you notice that it's sorta unique, cause you know it's me

  5. #5
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    this would give the user 2 attempts , if he failed the code will stop executing and showing "Contact your......"
    VB Code:
    1. Dim intCount As Integer = 0
    2.  
    3.     Private Sub grp1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles grp1.Click
    4.         Dim Username As String = New String("mark")
    5.         Dim Password As String = New String("pass")
    6.  
    7.         intCount = intCount + 1
    8.         If intCount >= 3 Then
    9.             MsgBox("Contact your administrator for more Info ")
    10.             Exit Sub
    11.         End If
    12.  
    13.         If (txtUser.Text) = "mark" And _
    14.         (txtPass.Text) = "Pass" Then
    15.             MsgBox("Logged in...", MsgBoxStyle.Information, "Logged in...")
    16.         Else
    17.             If Not (txtUser.Text) = "mark" Then
    18.                 MsgBox("worng username", MsgBoxStyle.Critical + MsgBoxStyle.OKOnly, "Auth")
    19.                 Exit Sub
    20.             Else
    21.                 If Not (txtPass.Text) = "pass" Then
    22.                     MsgBox("wrong password", MsgBoxStyle.Critical + MsgBoxStyle.OKOnly, "Auth.")
    23.                 End If
    24.             End If
    25.         End If
    26.     End Sub

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