Results 1 to 3 of 3

Thread: [RESOLVED] Question with is " isnothing(TextBox.Text)"

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2006
    Location
    Madrid
    Posts
    325

    Resolved [RESOLVED] Question with is " isnothing(TextBox.Text)"

    Hi
    I am trying to query when a textbox is nothing, but it doesn´t seem to work, and I can´t see nothing wrong with it,the code:

    VB Code:
    1. If Not IsNothing(TextBox1.Text) Then
    2.                  
    3. do sth
    4.  
    5. end if
    I have a textbox which I leave empty. "If not isnothing(textbox.text)" still evaluates to true, so runs the code in "do sth", when I think it should ignore the "do sth " code.


    I have run this in debug mode, and the textbox has the value of texbox1.text ="" , so the textbox is actually nothing.

    What is going on here?
    Thanks.

  2. #2
    Frenzied Member axion_sa's Avatar
    Join Date
    Jan 2002
    Location
    Joburg, RSA
    Posts
    1,724

    Re: Question with is " isnothing(TextBox.Text)"

    No, "Nothing" is the VB equivalent to null in C#/C++/Java - that statement is checking for a null value. As the .Text property will not return a null value, the "IsNothing" call will always evaluate to true.

    Your code should look like:
    Code:
    If TextBox1.Text.Length > 0 Then
        ''' Your code here.
    End If

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2006
    Location
    Madrid
    Posts
    325

    Re: Question with is " isnothing(TextBox.Text)"

    Thanks a lot;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width