double null question [2 * Null = Null] !!! 
Author Message
 double null question [2 * Null = Null] !!!

Interesting problem.  Null is a special type of the Varient variable.
How did you get them into the string?  I think you need to look at the
Asc values that are returned, are you sure they're not Ascii 0
characters (which are not Null, they are Chr$(0))  

If so, something like the following should work:

CutAt Instr(FixedStr, Chr$(0) & Chr$(0))

LFS

Quote:

> How do i search a string(without an looping) for a double null. I have
> returned a string and i need to know where the first double null is so i can
> truncate it at this point. What ive done is
> Preallocated a string buffer
> populated with a string from an API function and now i want to cut it. but
> nut at a single null(there are several of them i need)



Wed, 04 Jul 2001 03:00:00 GMT  
 double null question [2 * Null = Null] !!!
ASCII 0 is often called the null character.

Tom Shelton

Quote:

>Interesting problem.  Null is a special type of the Varient variable.
>How did you get them into the string?  I think you need to look at the
>Asc values that are returned, are you sure they're not Ascii 0
>characters (which are not Null, they are Chr$(0))

>If so, something like the following should work:

>CutAt Instr(FixedStr, Chr$(0) & Chr$(0))

>LFS


>> How do i search a string(without an looping) for a double null. I have
>> returned a string and i need to know where the first double null is so i
can
>> truncate it at this point. What ive done is
>> Preallocated a string buffer
>> populated with a string from an API function and now i want to cut it.
but
>> nut at a single null(there are several of them i need)



Thu, 05 Jul 2001 03:00:00 GMT  
 double null question [2 * Null = Null] !!!

Quote:

> ASCII 0 is often called the null character.

> Tom Shelton

Whoever is doing that, is misleading, or misrepresenting themselves.
You can add ASCII character 0's, to a string and cause that string
to increase in length.  Not so with Null.  An empty string IS often
referred to as a null string, which would be more correct.  See
IsNull.

Consider:

Dim B$
B = ">" & Null & Null & "<XXX>" & Chr$(0) & Chr$(0) & "<"
Print B

It produces a 9 character string "><XXX>..<"  where .. are those
box characters used to denote an unsupported character.  The Nulls
take up no space at all, thus an Empty string.

Have you got some VB documentation somewhere that states Chr$(0) is a
Null character???

Larry



Thu, 05 Jul 2001 03:00:00 GMT  
 double null question [2 * Null = Null] !!!

Quote:


>> ASCII 0 is often called the null character.

>Whoever is doing that, is misleading, or misrepresenting themselves.
>You can add ASCII character 0's, to a string and cause that string
>to increase in length.  Not so with Null.  An empty string IS often
>referred to as a null string, which would be more correct.  See
>IsNull.

It's official Larry, I'm afraid!  All the non-printable ASCII characters had
2- or 3-letter mnemonics and the one for Chr(0) was NUL (often expressed as
NULL of course). Like Chr(13) was CR and Chr(27) was ESC. More confusion has
been caused by Chr(127) which was DEL and Chr(8) which was BS (backspace),
both of which are usually confused with different keys now.

Bertie



Thu, 05 Jul 2001 03:00:00 GMT  
 double null question [2 * Null = Null] !!!
You might want to tell this to all the C/C++ programmers who have been using
null terminated strings all these many years.

Tom Shelton

Quote:


>> ASCII 0 is often called the null character.

>> Tom Shelton

>Whoever is doing that, is misleading, or misrepresenting themselves.
>You can add ASCII character 0's, to a string and cause that string
>to increase in length.  Not so with Null.  An empty string IS often
>referred to as a null string, which would be more correct.  See
>IsNull.

>Consider:

>Dim B$
>B = ">" & Null & Null & "<XXX>" & Chr$(0) & Chr$(0) & "<"
>Print B

>It produces a 9 character string "><XXX>..<"  where .. are those
>box characters used to denote an unsupported character.  The Nulls
>take up no space at all, thus an Empty string.

>Have you got some VB documentation somewhere that states Chr$(0) is a
>Null character???

>Larry



Thu, 05 Jul 2001 03:00:00 GMT  
 double null question [2 * Null = Null] !!!
So whos going to answer my Question????
Quote:

>You might want to tell this to all the C/C++ programmers who have been
using
>null terminated strings all these many years.

>Tom Shelton



>>> ASCII 0 is often called the null character.

>>> Tom Shelton

>>Whoever is doing that, is misleading, or misrepresenting themselves.
>>You can add ASCII character 0's, to a string and cause that string
>>to increase in length.  Not so with Null.  An empty string IS often
>>referred to as a null string, which would be more correct.  See
>>IsNull.

>>Consider:

>>Dim B$
>>B = ">" & Null & Null & "<XXX>" & Chr$(0) & Chr$(0) & "<"
>>Print B

>>It produces a 9 character string "><XXX>..<"  where .. are those
>>box characters used to denote an unsupported character.  The Nulls
>>take up no space at all, thus an Empty string.

>>Have you got some VB documentation somewhere that states Chr$(0) is a
>>Null character???

>>Larry



Fri, 06 Jul 2001 03:00:00 GMT  
 double null question [2 * Null = Null] !!!

Quote:

>So whos going to answer my Question????

Good question!

Warning - untested code...

DoubleNull = Chr$(0) & Chr$(0)
FoundPos = InStr(1, SearchString, DoubleNull)

Bertie



Fri, 06 Jul 2001 03:00:00 GMT  
 double null question [2 * Null = Null] !!!
Sorry Mike, I thought you caught it the first time around.  Here
it is again, at Deja News:

http://x4.dejanews.com/getdoc.xp?AN=433541164&CONTEXT=916662907.17140...

Its the same suggestion as Bertie's

Use Instr(FixedString, Chr$(0) & Chr$(0))

That should work!

Whoever decided Chr$(0) should be null, should have their head
examined.  I found it, listed in QBasic help (ASCII set).  0 is a
value (the value where no bits are set) therefore by definition,
it cannot be null.  But, if you all are going to use it that way,
I guess I'll shut up!  :)

hehe
LFS



Fri, 06 Jul 2001 03:00:00 GMT  
 double null question [2 * Null = Null] !!!
Larry,

You are correct that Chr(0) is not null.  It is, however, a *Null Character*
and can be represented by the vb constant vbNullChar.

vbNullChar = Chr(0)
vbNullString = ""  'zero length string
vbNull = 1   'TypeVar constant, indicates no valid data.

Your's (and Bertie's) solution is correct,  but i would generally write it
like this
pos = Instr(ReturnString, vbNullChar & vbNullChar)

Many API's return *null* terminated strings, and some use *double nulls*. An
example is GetProfileSection, each key/value is null terminated while the
entire string is double null terminated. It's up to the programmer to parse
the string.

David

Quote:

>Use Instr(FixedString, Chr$(0) & Chr$(0))

>That should work!

>Whoever decided Chr$(0) should be null, should have their head
>examined>LFS



Fri, 06 Jul 2001 03:00:00 GMT  
 double null question [2 * Null = Null] !!!
Hi David:

Quote:
>vbNullString = ""  'zero length string

vbNullString is *not* a zero length (empty) string -- it is a null pointer,
and there is a big difference.
For example, run these two statements in the debug window:

?StrPtr(vbNullString)
?StrPtr("")

You should get something similar to this:
 0
 7130036

Doug.



Sat, 07 Jul 2001 03:00:00 GMT  
 double null question [2 * Null = Null] !!!
Hi Doug,

Right!  I don't know where i was when i wrote that...
Thanks for the correction.

David

Quote:

>Hi David:

>>vbNullString = ""  'zero length string

>vbNullString is *not* a zero length (empty) string -- it is a null pointer,
>and there is a big difference.
>For example, run these two statements in the debug window:

>?StrPtr(vbNullString)
>?StrPtr("")

>You should get something similar to this:
> 0
> 7130036

>Doug.



Sat, 07 Jul 2001 03:00:00 GMT  
 double null question [2 * Null = Null] !!!
Hi David:

Quote:
>Right!  I don't know where i was when i wrote that...
>Thanks for the correction.

Done that before :)

Doug.



Sat, 07 Jul 2001 03:00:00 GMT  
 
 [ 12 post ] 

 Relevant Pages 

1. Null Null Null!!!!!!!!!

2. Null, Null, Null!

3. Alter Table with NULL/NOT NULL options

4. Null = Null Not Working ?

5. Null = Null error

6. null in vb and null in sql7

7. null not null

8. When is Null not Null

9. How can I pass NULL value to WinAPI which is expecting a NULL pointer

10. IS NULL vs = NULL - ODBC Drivers

11. To Null, or not to Null...?

12. Sending null strings and NULL values

 

 
Powered by phpBB® Forum Software