By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,646 Members | 2,105 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,646 IT Pros & Developers. It's quick & easy.

visual basic 2005 help

P: 13
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 NewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewToolStripMenuItem.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
Nov 9 '06 #1
Share this Question
Share on Google+
4 Replies


100+
P: 1,646
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 NewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewToolStripMenuItem.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.Visible = False

and

TextBox1.Visible = True

To make it reappear
Nov 9 '06 #2

P: 13
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
Nov 9 '06 #3

P: 13
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?
Nov 9 '06 #4

100+
P: 1,646
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.

Expand|Select|Wrap|Line Numbers
  1.  If condition Then
  2.    'do something here
  3.    Exit Sub 'this might be the part that is missing
  4. Else
  5.    'do something else here
  6. End If
  7.  
Nov 9 '06 #5

Post your reply

Sign in to post your reply or Sign up for a free account.