By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,695 Members | 1,221 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,695 IT Pros & Developers. It's quick & easy.

How can I open a file in a way that'll show me the NullChars?

P: n/a
Hi Gang,
I would like to open a compressed document of mine. The problem is part of
the compression algorithm contains character 0 which I need to detect. VB
sees character 0 as "" nothing and I can't detect nothing because 5 null
characters in a row would still be "". Does anyone know a way around this?
Do I open as binary or what? If so how?
Thanks in Advance,
Christian Blackburn
Nov 20 '05 #1
Share this Question
Share on Google+
12 Replies


P: n/a
Cor
Hi Christian,
I Character "0" is not nothing, it is has the byte value 48 like character
"1" has 49.
Maybe it is the binary value 0 you try to evaluate.
That I think you can reach with
\\\\
dim a as char = chr(0)
////
I hopes this helps you a little bit.
Cor
Nov 20 '05 #2

P: n/a
Hi Cor,
Thanks for the help. I think you are right that I was trying to detect
Chr(0), I assumed that was the nullchar, but as you have just said it's
chr(48). So as far as you know I should be able to detect each instance of
all 256 characters within the string datatype even when the string has more
than one character? You see I'm worried that the null characters won't be
added to the Len() value. Is my assumption correct?
Thanks again,
Christian
"Cor" <no*@non.com> wrote in message
news:3f**********************@reader20.wxs.nl...
Hi Christian,
I Character "0" is not nothing, it is has the byte value 48 like character
"1" has 49.
Maybe it is the binary value 0 you try to evaluate.
That I think you can reach with
\\\\
dim a as char = chr(0)
////
I hopes this helps you a little bit.
Cor

Nov 20 '05 #3

P: n/a
Nearly Christian. Cor put you little crook but ...

NullChar is Chr(0). It is aka vbNullChar.

Chr(48) is 0 aka Zero.

NullChar's are definitely included in the Len() and .Length values.

<string>.IndexOf(NullChar) will return the index of the first occurrence of
a NullChar in the string or -1 if the string does not contain any.

If you want to get rid of them use <string> = <string>.Replace(NullChar,"").
This will reduce the Len() or .Length values by the number of NullChar's
that were in the string originally.

"Christian Blackburn" <Christian@Damn@Sp**@Hotmail.com> wrote in message
news:%2******************@TK2MSFTNGP11.phx.gbl...
Hi Cor,
Thanks for the help. I think you are right that I was trying to detect
Chr(0), I assumed that was the nullchar, but as you have just said it's
chr(48). So as far as you know I should be able to detect each instance of all 256 characters within the string datatype even when the string has more than one character? You see I'm worried that the null characters won't be
added to the Len() value. Is my assumption correct?
Thanks again,
Christian
"Cor" <no*@non.com> wrote in message
news:3f**********************@reader20.wxs.nl...
Hi Christian,
I Character "0" is not nothing, it is has the byte value 48 like character "1" has 49.
Maybe it is the binary value 0 you try to evaluate.
That I think you can reach with
\\\\
dim a as char = chr(0)
////
I hopes this helps you a little bit.
Cor


Nov 20 '05 #4

P: n/a
Hi Cor,
Okay I just checked an the NullChar is indeed Chr(0). I guess I got a
little confused there :). I read " I Character "0" is not nothing, it is
has the byte value 48 like character" and interpreted it as "The NulL
Character is not nothing, it is has the byte value 48...". It would seem my
interpreter is flawed, oh well Microsoft ain't got nothing on my interpreter
:).
Cheers,
Christian Blackburn

"Christian Blackburn" <Christian@Damn@Sp**@Hotmail.com> wrote in message
news:%2******************@TK2MSFTNGP11.phx.gbl...
Hi Cor,
Thanks for the help. I think you are right that I was trying to detect
Chr(0), I assumed that was the nullchar, but as you have just said it's
chr(48). So as far as you know I should be able to detect each instance of all 256 characters within the string datatype even when the string has more than one character? You see I'm worried that the null characters won't be
added to the Len() value. Is my assumption correct?
Thanks again,
Christian
"Cor" <no*@non.com> wrote in message
news:3f**********************@reader20.wxs.nl...
Hi Christian,
I Character "0" is not nothing, it is has the byte value 48 like character "1" has 49.
Maybe it is the binary value 0 you try to evaluate.
That I think you can reach with
\\\\
dim a as char = chr(0)
////
I hopes this helps you a little bit.
Cor


Nov 20 '05 #5

P: n/a
"Christian Blackburn" <Christian@Damn@Sp**@Hotmail.com> schrieb
Hi Cor,
Thanks for the help. I think you are right that I was trying to
detect Chr(0), I assumed that was the nullchar, but as you have just
said it's chr(48). So as far as you know I should be able to detect
each instance of all 256 characters within the string datatype even
when the string has more than one character? You see I'm worried
that the null characters won't be added to the Len() value. Is my
assumption correct? Thanks again,
Christian


You can work with Chr(0) like with any char. The only problem is that the
IDE does not _display_ the text behind chr(0) and you might get problems
when calling API functions, but working with chr(0) (and all other
characters) should not be a problem. Concerning the Len function:

Dim s As String = "abd" & Chr(0) & "efg"
MsgBox(Len(s))

Msgbox shows 7. So, I don't see the problem. You can also use s.Length.
--
Armin

Nov 20 '05 #6

P: n/a
Hi Stephany,
Wow I think you're the first woman I've seen in this group. Of course with
so many foreigners in this group I might not recognize a female name if she
was from another nationality.

You seem to have good answers.
Nearly Christian. Cor put you little crook but ...

NullChar is Chr(0). It is aka vbNullChar.
Good that was what I had always thought :).

Chr(48) is 0 aka Zero.

NullChar's are definitely included in the Len() and .Length values.
I was not aware of that though and that's good to know :).


<string>.IndexOf(NullChar) will return the index of the first occurrence of a NullChar in the string or -1 if the string does not contain any.
Hey thanks I saw that and wondered what the hell it did, but never bothered
to read the bloated MSDN help on it. That's an excellent function it's like
a quick version of Instr.
If you want to get rid of them use <string> = <string>.Replace(NullChar,""). This will reduce the Len() or .Length values by the number of NullChar's
that were in the string originally.


Thanks for all the help,
Christian Blackburn
Nov 20 '05 #7

P: n/a
Hi Armin,
Yes I think you're right, I was expecting a "AB " where the null character
was when I moused over the string variable's value.
Thanks Again,
Christian Blackburn

"Armin Zingler" <az*******@freenet.de> wrote in message
news:ey**************@tk2msftngp13.phx.gbl...
"Christian Blackburn" <Christian@Damn@Sp**@Hotmail.com> schrieb
Hi Cor,
Thanks for the help. I think you are right that I was trying to
detect Chr(0), I assumed that was the nullchar, but as you have just
said it's chr(48). So as far as you know I should be able to detect
each instance of all 256 characters within the string datatype even
when the string has more than one character? You see I'm worried
that the null characters won't be added to the Len() value. Is my
assumption correct? Thanks again,
Christian


You can work with Chr(0) like with any char. The only problem is that the
IDE does not _display_ the text behind chr(0) and you might get problems
when calling API functions, but working with chr(0) (and all other
characters) should not be a problem. Concerning the Len function:

Dim s As String = "abd" & Chr(0) & "efg"
MsgBox(Len(s))

Msgbox shows 7. So, I don't see the problem. You can also use s.Length.
--
Armin

Nov 20 '05 #8

P: n/a
Cor

"Christian Blackburn
Thanks for the help. I think you are right that I was trying to detect
Chr(0), I assumed that was the nullchar, but as you have just said it's
chr(48). So as far as you know I should be able to detect each instance of all 256 characters within the string datatype even when the string has more than one character? You see I'm worried that the null characters won't be
added to the Len() value. Is my assumption correct?


Some code to test a lot of thinks that you did ask last hours
When you use this, with me I saw that the string lengths are given correct.
\\\\
Dim ls, lsa, iAsChar As String
Dim i As Integer
Dim s As String = ("00000000")
i = Convert.ToInt32(s, 2)
iAsChar = Chr(i)
For y As Integer = 0 To 9
ls = ls & Asc(iAsChar) & Asc("0")
lsa = lsa & iAsChar & "0"
Next
MessageBox.Show(ls.Length.ToString & "=" & ls & "||" &
Len(lsa).ToString & "=" & lsa)
/////
I did use the length member and the Len function. The results are the same
if you change them.
Cor
Nov 20 '05 #9

P: n/a
Cor
Stephany,
The vbNullChar is the binary value zero.
0 is the arabian charachter for the value zero. It is also used in most
modern European languages.
:-)
Cor

Nov 20 '05 #10

P: n/a
"Cor" <no*@non.com> wrote in news:3f**********************@reader20.wxs.nl:
The vbNullChar is the binary value zero.
0 is the arabian charachter for the value zero


Um, I believe that's what she said.

Cheers,

Chris
Nov 20 '05 #11

P: n/a
Cor
Christian
I doubt it, but I don't know what an aka is.
But important for you is, that you understand that 48 is only a codenumber
in some code tables and absolute not in all code tables.
It is never a value (except of course the code value).
Cor
Nov 20 '05 #12

P: n/a
Hi Herfried,
Thanks for the info that's good to know.
-Christian

"Herfried K. Wagner [MVP]" <hi*******@m.activevb.de> wrote in message
news:uz**************@TK2MSFTNGP10.phx.gbl...
Hello,

"Cor" <no*@non.com> schrieb:
That I think you can reach with
\\\\
dim a as char = chr(0)
Notice that the nullchar is available through 'ControlChars.NullChar' too

in VB.NET.

--
Herfried K. Wagner
MVP VB Classic, VB.NET
http://www.mvps.org/dotnet

Nov 20 '05 #13

This discussion thread is closed

Replies have been disabled for this discussion.