visual basic 2005 help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • andrew4862
    New Member
    • Oct 2006
    • 13

    visual basic 2005 help

    Simple one for you guys i hope, bit of a newbie at this:

    i have a text box that i need to be filled in i have a statement to display a text box if it is blank which works but it still moves on to the next screen how do i end the process if it is blank and display the message?

    Private Sub NewToolStripMen uItem_Click(ByV al sender As System.Object, ByVal e As System.EventArg s) Handles NewToolStripMen uItem.Click
    If TextBox1.Text = "" Then MsgBox("Fill in Name") Else
    Label6.Text = TextBox1.Text
    TextBox1.Hide()
    Label5.Hide()
    Label6.Show()
    Label7.Show()

    This is what i got thanks for your help
  • willakawill
    Top Contributor
    • Oct 2006
    • 1646

    #2
    Originally posted by andrew4862
    Simple one for you guys i hope, bit of a newbie at this:

    i have a text box that i need to be filled in i have a statement to display a text box if it is blank which works but it still moves on to the next screen how do i end the process if it is blank and display the message?

    Private Sub NewToolStripMen uItem_Click(ByV al sender As System.Object, ByVal e As System.EventArg s) Handles NewToolStripMen uItem.Click
    If TextBox1.Text = "" Then MsgBox("Fill in Name") Else
    Label6.Text = TextBox1.Text
    TextBox1.Hide()
    Label5.Hide()
    Label6.Show()
    Label7.Show()

    This is what i got thanks for your help
    Hi. Don't know about this Hide() method.
    In VB6 to make a control disappear you need to set the visible property to false

    TextBox1.Visibl e = False

    and

    TextBox1.Visibl e = True

    To make it reappear

    Comment

    • andrew4862
      New Member
      • Oct 2006
      • 13

      #3
      the rest works and the show and hide is fine its just i want to know how to stop it going to that stage if the box is blank. i can get it to display the text box but when you press ok it still goes to the next stage i wnat to know what to type to stop it

      Comment

      • andrew4862
        New Member
        • Oct 2006
        • 13

        #4
        Originally posted by andrew4862
        the rest works and the show and hide is fine its just i want to know how to stop it going to that stage if the box is blank. i can get it to display the text box but when you press ok it still goes to the next stage i wnat to know what to type to stop it
        sorry i mean msgbox not text box! I can get it to display the msgbox but it then still goes to the next stage what do i need to type to stop it?

        Comment

        • willakawill
          Top Contributor
          • Oct 2006
          • 1646

          #5
          Originally posted by andrew4862
          sorry i mean msgbox not text box! I can get it to display the msgbox but it then still goes to the next stage what do i need to type to stop it?
          OK I see.
          The structure of the If..Then..Else. .End If block is important
          There is no speed improvement by writing it on one line.

          Code:
           If condition Then
             'do something here
             Exit Sub 'this might be the part that is missing
          Else
             'do something else here
          End If

          Comment

          Working...