467,874 Members | 1,727 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,874 developers. It's quick & easy.

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 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
  • viewed: 1729
Share:
4 Replies
1GB
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
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
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
1GB
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.

Similar topics

2 posts views Thread by elnahrawi | last post: by
97 posts views Thread by Master Programmer | last post: by
11 posts views Thread by =?Utf-8?B?UGV0ZXI=?= | last post: by
4 posts views Thread by Goran Djuranovic | last post: by
reply views Thread by jack112 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.