Dont run function if text box empty in VB

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

B3gbie

Thread Starter
Joined
Nov 30, 2001
Messages
228
I'm trying to return an error if a particular text box is empty,
if txtWhatever.text ="" Then doesnt work, I have some code to convert null values to empty strings but it doesnt want to work with this bit, any help would be appreciated.
 
Joined
May 20, 2000
Messages
11
Is the test for valid text being executed? Start a new project and put a text box on the form. Clear the default text from the box and in the form unload event put

If Text1.text = "" Then
Msgbox "Error"
Cancel = 1
Endif

Try it by running the project and closing the form. If there is nothing in the text box you will get the error message and the form will remain displayed. If you do the same thing after putting something in the text box the project will terminate.
Why are you looking for nulls in a text box, as far as I am aware a text box can never have a null value.
 

B3gbie

Thread Starter
Joined
Nov 30, 2001
Messages
228
Found the problem, had tried your solution but with no joy, turns out I was calling the function with an integer, hence the error, thanks for your help anyway though, i didn't know about the null bit. :)
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Members online

Top