1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Dont run function if text box empty in VB

Discussion in 'Software Development' started by B3gbie, Jan 18, 2002.

Thread Status:
Not open for further replies.
  1. B3gbie

    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.
     
  2. Harryc

    Harryc

    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.
     
  3. B3gbie

    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. :)
     
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 733,556 other people just like you!

Loading...
Similar Threads - Dont function text
  1. dlipman
    Replies:
    0
    Views:
    444
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/65358

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice