Results 1 to 5 of 5

Thread: [RESOLVED] Problem with VBNULL

  1. #1

    Thread Starter
    Member
    Join Date
    May 2006
    Posts
    40

    Resolved [RESOLVED] Problem with VBNULL

    If rsAttrib("Description").Value <> vbNull Then
    strCondDesc = rsAttrib("Description").Value
    End If
    Above code is wrttten in vb6.0

    Datatype for Column Description is varchar and above code works fine except one case.

    If value of Description is “1” then it won’t enter the If block as in visual basic 6.0 VBNULL is enumeration and its value is 1. I want it to execute for 1 also.

    Please give me some suggestion.
    how can i handle this.
    Last edited by Hack; Dec 19th, 2007 at 08:08 AM. Reason: Added RESOLVED to thread title and green resolved checkmark

  2. #2
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: Problem with VBNULL

    Empty uninitialized string is vbNullString. This is equivalent of NULL in C.


    You can also check for empty string by using LenB(strText) = 0 - this is actually faster than checking for vbNullString.

  3. #3

    Thread Starter
    Member
    Join Date
    May 2006
    Posts
    40

    Re: Problem with VBNULL

    rsAttrib is recordset. and if the value is Null in Description , if you try to assign it to some variable it gives error. Even finding length won't work in this case.

    I tried to compare with vbNullString, but vbNullString is empty string not NULL.

  4. #4
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: Problem with VBNULL

    In that case: you're getting a Variant. With Variants you can use:

    If IsNull(rsAttrib("Description").Value) Then

    You can also find IsEmpty and some other functions that only work with Variants. You can find these by opening up the Object Browser by pushing F2.



    (I'm not too familiar with recordsets.)

  5. #5

    Thread Starter
    Member
    Join Date
    May 2006
    Posts
    40

    Re: Problem with VBNULL

    Hey Thanks.


    It's working

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