'And'ing a Byte Value - How?

A

Arnold Shore

Folks, I get a TYPE MISMATCH complaint fm ASP when I do the following in
trying to extract the high-order four bits. The complaint being that the
strTemp value is a string. Well, yes - it's a 1-char string.

NumTemp = MidB(strTemp,1, 1) And &Hf0

What am I doing wrong? (Something dumb, I'm sure, but ... .)

AS
 
C

Chris Hohmann

Arnold Shore said:
Folks, I get a TYPE MISMATCH complaint fm ASP when I do the following in
trying to extract the high-order four bits. The complaint being that the
strTemp value is a string. Well, yes - it's a 1-char string.

NumTemp = MidB(strTemp,1, 1) And &Hf0

What am I doing wrong? (Something dumb, I'm sure, but ... .)

NumTemp = AscB(strTemp) And &HF0

Notes:
1. No need to extract the first character, Asc/AscB/AscW only act on the
first character in a string.
2. Here is the reference page for Asc/AscB/AscW in VBScript:

http://msdn.microsoft.com/library/en-us/script56/html/vsfctasc.asp

HTH-
Chris Hohmann
 
A

Arnold Shore

Yep. Now back to my question: How do I extract the extract the high-order
four bits of a given Byte value?

The logical "And" for that requires a numeric expression, and I have a Byte.

AS

"Chris Hohmann" <hohmannATyahooDOTcom> wrote in message
....
 
C

Chris Hohmann

Arnold Shore said:
Yep. Now back to my question: How do I extract the extract the high-order
four bits of a given Byte value?

The logical "And" for that requires a numeric expression, and I have a
Byte.

TypeName(MidB("SomeString",1,1)) => String
TypeName(AscB("SomeString")) => Byte

Did you try the following line?

NumTemp = AscB(strTemp) And &HF0


HTH
-Chris Hohmann
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,126
Messages
2,570,750
Members
47,307
Latest member
Wimble

Latest Threads

Top