dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: How to directly move from msgbox to form1

  1. #1
    Join Date
    Feb 2010
    Posts
    16

    How to directly move from msgbox to form1

    Hi, i am having a problem on my program

    Private Sub Command1_Click()
    If text1.Text = "" Then
    MsgBox ("You have no content on your 1st Textbox")
    Else
    End If
    .
    .
    .
    Bunch of codes that will result to an error if there is no value for text1.text


    When the user clicks the command button and the textbox is blank, there will be a msgbox popping out.

    But how can i make the program go back to the form1 without continuing the program since there would be errors after the first if statement

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: How to directly move from msgbox to form1

    Ever push F1 for Help? If you went to the word SUB and did it, you'd see the syntax of the command. (works for all of them!)

    Code:
    Else
     Exit Sub
    End If
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Feb 2010
    Posts
    16

    Re: How to directly move from msgbox to form1

    Quote Originally Posted by dglienna View Post
    Ever push F1 for Help? If you went to the word SUB and did it, you'd see the syntax of the command. (works for all of them!)

    Code:
    Else
     Exit Sub
    End If
    oh, i just used the portable version of vb 6.0 and there's no help on it.. really sorry,

    uhm about the code it still has an error, so far this is what i got sir

    Code:
    Private Sub Command1_Click()
    If text1.Text = "" Then
    MsgBox ("You have no content on your 1st Transformation Matrix")
    Else
     Exit Sub
    End If
    'this is the next code after End If
    text2.text= text1.text + 1
    It says Run-time error '9':

    Type mismatch
    Last edited by lloydi12345; March 3rd, 2010 at 07:30 PM.

  4. #4
    Join Date
    Feb 2008
    Location
    Bangalore
    Posts
    149

    Re: How to directly move from msgbox to form1

    Code:
    Private Sub Command1_Click()
    If text1.Text = "" Then
    MsgBox ("You have no content on your 1st Transformation Matrix")
     Exit Sub '<-- Required here
    
    Else
     'Exit Sub <--- Not required, here you can write your execution code
    
    End If
    'this is the next code after End If
    text2.text= text1.text + 1 '<--- Here you may end up with wrong results 
    'If you are performing mathematical operation and if the value in textbox is non numeric??
    'my advice is write a different Sub or function to validate the text in textbox before manipulating
    Encourage the efforts of fellow members by rating

    Lets not Spoon Feed and create pool of lazy programmers

    - ComIT Solutions

  5. #5
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: How to directly move from msgbox to form1

    Make sure you can't put A in the box, or 1,234.00
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  6. #6
    Join Date
    Feb 2010
    Posts
    16

    Re: How to directly move from msgbox to form1

    very good sir! now im done thanks really

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)