Results 1 to 2 of 2

Thread: VB Innovative Log-In Form Improvement

  1. #1

    Thread Starter
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    VB Innovative Log-In Form Improvement

    I have made this simple log-in form but I know its not perfect, I will appreciate if if anybody could pinpoint the bugs in it.... I am thinking I could make that textbox into an .ocx, perhaps adding a property that would be displayed as the mask of the control but I still dont have time.....
    Attached Files Attached Files
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  2. #2
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Re: VB Innovative Log-In Form Improvement

    OK. I'm just gonna list things wrong with it in no particualr order.

    VB Code:
    1. Private Function UserIsExisting(ByVal UserPassword As String) As Boolean
    2.     If StrComp(HiddenPassword, "rodelio", 0) = 0 Then
    3.         UserIsExisting = True
    4.     Else
    5.         UserIsExisting = False
    6.     End If
    7. End Function
    What is the point of passing the param UserPassword into this function?

    There is no X on the login form...how is a user supposed to exit it?

    VB Code:
    1. frmDenied.Show 1
    Should be:
    VB Code:
    1. frmDenied.Show vbModal
    Does the same thing, but it uses the correct constant and is easier to read.

    VB Code:
    1. Private b As Integer, PasswordLenght As Integer
    Don't do this...it makes it hard to see what varibles are declared.
    Always do:
    VB Code:
    1. Private b As Integer
    2. Private PasswordLenght As Integer

    You may want to add naming conventions to your app.

    str = string
    int = integer
    lng = long
    bln = boolean
    dte = date
    cur = currency
    dbl = double
    sng = single
    byt = byte

    so you would declare varibles like:
    VB Code:
    1. Dim lngCount As Long
    2. Dim dteBirthday As Date
    3. Dim curWage  As Currency
    This makes code MUCH MUCH easier to read and to see what's going on.

    If the varible if at modular level, ie at the top of the form, for example in your case lets take the varible EnteredValues.
    You proceed this with "m" which stands for modular level varible. This would be:
    VB Code:
    1. Private mstrEnteredValues As String
    I use "p" for parameters passed into functions also, but some coders don't. It's entirely up to you. For example:
    VB Code:
    1. Private SUb Login(ByVal pstrUsername As String, Byval pstrPassword As String)
    2. Dim strSQL As String
    3. Dim adoRec As Recordset
    4.     'code to check if username and password are correct in DB
    5. End Sub

    Instead of using DoEvents in your Timer1_Timer event I would add the following to the end of the function:
    VB Code:
    1. lblKeyIn1.Refresh
    2. lblKeyIn2.Refresh
    DoEvents is used far to often in the wrong circumstances This can cause all sorts of unknown and evil problems to occur if you're not carefull...a small exmaple is to create a new project then add the following:
    VB Code:
    1. Private Sub Command1_Click()
    2. Dim lngIndex As long
    3. Dim lngOtherNum As Long
    4.    For lngIndex = 1 To 1000000
    5.       DoEvents
    6.       lngOthernum = lngIndex
    7.    Next lngIndex
    8. End Sub
    Click the command button and then close your form down by clicking the X. Notice how your app doesn't unload

    That's all I can see for starters...but I think the main question is why you would want a login form like this?

    Woka

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