Results 1 to 7 of 7

Thread: To check an empty string into a variable

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2004
    Location
    Barcelona
    Posts
    70

    To check an empty string into a variable

    How can I check an empty string into a variable?

    For instance, I want to check if the 'Var2' is equal to empty string (I mean nothing):
    Code:
    If ((Var1 = 7) AND (Var2 = "")) Then
            value.IsValid = False
            Exit Sub
    End If
    In this way (Var 2= "") doesn' t run

    Thanks,
    Cesar

  2. #2
    Member
    Join Date
    Jan 2003
    Posts
    44
    You could do Len(var2) = 0

    Frank

  3. #3
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    .Length method of string type is the pure .NET way if you want to do it that way . Len is imported from Microsoft.VisualBasic which is only for compatiblity support .

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Feb 2004
    Location
    Barcelona
    Posts
    70
    It does the same . I don' t understand why? The 'Var2' is a text field in an aspx web form page.

    If I put this, runs:
    Code:
    ...
    If ((Var1 = 7) AND (Var2 = 2)) Then
            value.IsValid = False
            Exit Sub
    End If
    ...
    But I want to check an empty string to 'Var2'...

    Any suggestions?

  5. #5
    Member
    Join Date
    Jan 2003
    Posts
    44
    thanks Pirate.

    Didn't know that, I will use .length instead.

    Frank

  6. #6
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    I don't understand this neither , try removing the round brackets and replace 'And' for 'AndAlso' . See if this makes any difference .

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Feb 2004
    Location
    Barcelona
    Posts
    70
    It does the same.. The normal way is (Var2 = "") when the object that represents 'Var2' is an asp.net text box?

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