home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Ask a Tech Support Question (free)!

VB Help with Void Null

Reply
Get bargains at  »  Dealighted.com
 
Thread Tools Search this Thread
Currently Active Users: 1515
Discussions: 200,952, Posts: 2,379,474, Members: 246,315
Old April 14th, 2005, 12:47 AM   Digg it!   #1 (permalink)
Member
 
redfoxstorm's Avatar
 
Join Date: Feb 2005
Posts: 386
VB Help with Void Null

I've wrote a small VB program that except input through a textbox. After I wrote the program I want to know what is the code that will allow me to print out an error message when nothing is entered?

How can do it with a if statment? Like

if textbox1.text = null then

"label1.text = " No Input"

End If


Thats all i want to do....can anybody help?

RedFox
__________________
For the Emperor, there were the Jedi. For the Evil Empire of Microsoft, there is a penguin.
redfoxstorm is offline   Reply With Quote
Old April 14th, 2005, 01:03 AM     #2 (permalink)
Perfetc Member
 
VHockey86's Avatar
 
Join Date: Jan 2003
Location: Maryland Suburbia
Posts: 4,334
isnt there an "isEmpty" method (function) or something?
Haven't used VB in awhile, but i dont see why this wouldnt work

if textBox1.text() = "' then
whatever
end if

Those are two quotation marks with no space inbetween them.

Last edited by VHockey86 : April 14th, 2005 at 01:10 AM.
VHockey86 is offline   Reply With Quote
Old April 14th, 2005, 03:25 AM     #3 (permalink)
Member
 
redfoxstorm's Avatar
 
Join Date: Feb 2005
Posts: 386
didn't work
redfoxstorm is offline   Reply With Quote
Old April 14th, 2005, 03:52 AM     #4 (permalink)
Member
 
redfoxstorm's Avatar
 
Join Date: Feb 2005
Posts: 386
I keep getting a "cast from string "" to Integer is not valid"

whats that mean?
redfoxstorm is offline   Reply With Quote
Old April 14th, 2005, 04:32 AM     #5 (permalink)
Ultimate Member
 
Join Date: Dec 2004
Posts: 1,558
Try:
Code:
If textbox1.Text = "" Then
label1.Text = "No Input"
End If
If that doesn't work, check your data types (in all your statements) because something is wrong there. That's what's causing the type cast error.
large_nostril is offline   Reply With Quote
Old April 14th, 2005, 10:48 AM     #6 (permalink)
Perfetc Member
 
VHockey86's Avatar
 
Join Date: Jan 2003
Location: Maryland Suburbia
Posts: 4,334
... is your textbox somehow like a "number box" ?
I agree, that is very weird. I would think that everything is treated as a string from a text box.
Perhaps what you need to do is stop the current function if that error occurs.

It's probably trying to use that data later on in your program execution since setting a label to "no input" never actually stops the rest of it from executing.

You probably want to do something like

If Not textbox1.Text = "" Then
//call a function to continue execution
Else
label1.Text = "No Input", (might also want to consider using a message box here, not so discrete)
End If

Another way around it would be to set

textbox1.Text = 0 if there is no input (so, in the else statement above).
VHockey86 is offline   Reply With Quote
Old April 14th, 2005, 11:02 AM     #7 (permalink)
ph34r t3h g04t
 
Whir's Avatar
 
Join Date: Oct 2001
Location: Kingsford, MI
Posts: 19,558
Blog Entries: 7
In the button code, put this:

If txtbox1.Text = "" Then MsgBox "No Input"

Second, just setting a label.Text to a variable will not update the forum until you do a frmWhatever.Refresh (I think is the method - it's been a while).

Third, since this isn't a multiple line statement If, you don't need to get fancy with an End If. Just tack a MsgBox behind the Then and call it a day.

BTW, the MsgBox makes a pop up box. If you WANT the form to be updated (not how you would normally want the program to work), then you should do the lblLabel.Text = "No Input" and frmForm.Refresh inside a normal If, Then, End If.

Make sense?
Whir is offline   Reply With Quote
Old April 14th, 2005, 11:07 AM     #8 (permalink)
ph34r t3h g04t
 
Whir's Avatar
 
Join Date: Oct 2001
Location: Kingsford, MI
Posts: 19,558
Blog Entries: 7
Quote:
Originally Posted by VHockey86
isnt there an "isEmpty" method (function) or something?

isEmpty works if the variable is either set to empty, or the variable is uninitialized. Even if there's no input to the box, I believe it will still be "" rather than empty.
Whir is offline   Reply With Quote
Old April 14th, 2005, 11:46 AM     #9 (permalink)
Ultimate Member
 
Join Date: Jan 2003
Location: MA / NH
Posts: 1,497
Send a message via AIM to Blazer06
The code that you would need to have is:

Code:
Private Sub subCheck()
If text1.text = “” then
	‘If there is no input
	Lable1.caption = “No Input”
Else
	‘If there is input
	Lable1.caption = “Input”
End if
End Sub
Then just call subCheck when you needed to check.


-Blaze
Blazer06 is offline   Reply With Quote
Old April 14th, 2005, 11:47 AM     #10 (permalink)
Not Really a Member
 
Join Date: Oct 2001
Posts: 25,386
have you tried
If CStr(txtBox.Text) = "" Then

OR Worst case scenario

Dim vSomeVar As Variant
vSomeVar = txtBox.Text
If vSomeVar = "" Then

or even worster scenario (this shouldn't even work seeing as a text box can't handle a NULL value
If IsNull(txtBox.Text) Then
__________________
Helicopters don't fly; they vibrate so much and make so much noise that the earth rejects them.
vass0922 is offline   Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Similar Threads
Thread Thread Starter Forum Replies Last Post
Null and Void according to California Supreme Court FTM IMO Community 7 August 13th, 2004 01:16 AM
C++ question on void functions. Elburn Webmastering and Programming 6 February 12th, 2004 08:35 PM
Arctic Sillver will void your AMD warranty. Theophylact Processors, Memory, and Overclocking 13 April 30th, 2003 10:05 PM
redhat null: anyone know about it? storm2k Applications and Operating Systems 3 August 24th, 2002 01:55 PM
XML to void out the C language? newbie~wan Webmastering and Programming 31 April 2nd, 2002 11:41 AM


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Most Active Discussions
The disrespect of Obama by Russian .. (41)
Is It Just Me? (2942)
Making Health Care Worse (178)
Wireless Televisions. (12)
CPU fan stops spinning randomly (8)
windows 7 problem (7)
Regular Build (11)
Is the PSU I received dead? (12)
radeon x850xt platinum & shader.. (6)
Print spooler problem (15)
windows vista security holes (10)
HIS HD5770 graphic card question (15)
Install XP pro and a Vista laptop ?.. (11)
Foreign voltage (10)
Recent Discussions
How to Enjoy Your Favorite Videos on .. (0)
EVGA 9800 gtx help with finding a goo.. (11)
Regular Build (11)
Help with onclick and buttons (0)
Modern Warfare 2: Who Bought It? (63)
Virus advise (8)
My monitor won't turn on after instal.. (1)
Laptop with wireless problem. (3)
Internet Lost (3)
Dept. of HS: NSA 'Helped' Develop Vis.. (16)
windows vista security holes (10)
Point and Shoot Camera Suggestions. (4)
Multiple Restarts Required at Boot (2)
Ideal cheap graph card for PC-Gaming? (18)
radeon x850xt platinum & shader 3 (6)
Graphics Card Upgrade Question (4)
For Sale BFG GTX285 OC2 with 10 year .. (3)
How to convert MP3's (4)
Wireless Televisions. (12)
Hp Artist Edition + Matching Bag (0)
Asus P4G8X Mobo (6)
Xbox 360 GTA: SA disk error (1)
Is the PSU I received dead? (12)
windows 7 internet problem (5)
BSOD On Startup (ntoskrnl.exe) (2)


All times are GMT -4. The time now is 02:31 AM.
TechIMO Copyright 2009 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28