Re: InStr and striping NULs
- From: "Howard Kaikow" <kaikow@xxxxxxxxxxxxx>
- Date: Thu, 8 Nov 2007 16:39:31 -0500
"Mike Williams" <mikea@xxxxxxxxxxxxxxxxx> wrote in message
news:%23XTZYwgIIHA.6108@xxxxxxxxxxxxxxxxxxxxxxx
How have you declared it? If it's a constant then you can't have usedConst
cNul = Chr$(0) because VB would complain about an expression being used ina
constant declaration. In that case you might have been tempted do doautomatic
something like Const cNul = 0 or perhaps even Const cNul as String = 0. If
that's what you have done then VB will happily accept it, but VB's
type conversion will actually create a string using the Ascii code of thethat
"zero digit character" (Chr$(48)) which of course will cause your code to
fail to work as expected. However, if you have used Public cNul as String
(using either a standard variable length string or a fixed length one) and
if you have at some point in your startup procedure assigned Chr$(0) to
variable then all will be fine. In that case you need to check that yourthat
initialisation code is being run correctly before you use the variable.
Perhaps you have declared this variable differently in this one program
is giving you problems, or perhaps there is another variable of the same
name, but with different contents, in scope in this specific project. It's
hard to say really what the exact problem is without looking at all your
declarations, which you haven't shown.
In the troublesome project:
1. The following are used in a public module
Public cNul As String
cNul = Chr$(0)
2. The code assigning cNul is invoked by the Form Load event before the
first use of cNul.
3. There are no other declarations of, or assignments to, cNul in the
project.
The ONLY use of cNul is in the statement in my original posting
Filename = WFD.cFileName
' k = InStr(Filename, cNul)
k = InStr(Filename, Chr$(0))
Where
WFD is defined by
Private WFD As WIN32_FIND_DATA
And the value is returned by FindFirstFileW/FindNextFileW
.
- Follow-Ups:
- Re: InStr and striping NULs
- From: Howard Kaikow
- Re: InStr and striping NULs
- References:
- InStr and striping NULs
- From: Howard Kaikow
- Re: InStr and striping NULs
- From: Mike Williams
- InStr and striping NULs
- Prev by Date: Re: alternative to gettickcount
- Next by Date: Re: discover Office add-ins
- Previous by thread: Re: InStr and striping NULs
- Next by thread: Re: InStr and striping NULs
- Index(es):