Results 1 to 3 of 3

Thread: Help me!!

  1. #1

    Thread Starter
    Lively Member Skateboarder's Avatar
    Join Date
    Nov 2000
    Location
    Delfzijl, the Netherlands
    Posts
    66

    Question

    Ok... i have this simple script but it does not seem to
    work. I have a form with two textboxes. I want to retrieve
    a time from the user. My script was doing just fine, until
    I wanted to limit the input for seconds to 59. Caus' i.e.
    2 minutes and 74 seconds is weird. So it made a simple
    change. But now my script is acting weird and i get the
    wrong messageboxes at the wrong moment. I just want a time
    and when the user presses a button, it starts calculating
    with it... can anybody HELP ME?

    Here's my code:
    Code:
    Private Sub Command1_Click()
    
    If Text1.Text = "" Then
    GoTo error1
    ElseIf Text2.Text = "" Then
    GoTo error1
    End If
    
    If IsNumeric(Text1.Text) Then GoTo proceed Else GoTo error2
    If IsNumeric(Text2.Text) Then GoTo proceed Else GoTo error2
    
    proceed:
    If Text2.Text > 59 Then
    GoTo error3
    Else
    calculate
    End If
    
    error1:
    MsgBox "Please enter a value"
    GoTo endsub
    
    error2:
    MsgBox "Please enter a number"
    GoTo endsub
    
    error3:
    MsgBox "Seconds must be below 60"
    GoTo endsub
    
    endsub:
    End Sub
    Since this:
    Code:
    If Text2.Text > 59 Then
    it is acting weird...

  2. #2

    Thread Starter
    Lively Member Skateboarder's Avatar
    Join Date
    Nov 2000
    Location
    Delfzijl, the Netherlands
    Posts
    66

    I am so dumb...

    never mind...
    i forgot to put goto endsub at the end of that part...
    so it calculated the stuff... and then did a msgbox
    with "please enter a value".... I am so dumb...
    To VB or not to VB, that's the question...

  3. #3
    Addicted Member Ramandeep's Avatar
    Join Date
    Feb 2000
    Posts
    158
    Get rid of the old fashion goto **** statements and write structural code, also indent code to help your self and others read it easer. Although this program is small and straightforward I could imagine what your bigger programs would be like, hell for any one trying to debug it.

    Didn't mean to offend you, just trying to help you improve your coding style. I tell all my mates the same thing, it makes it easer to sort any problem they have because the code is much clearer.


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