Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert Char To Binary

Status
Not open for further replies.

JRudisill

Programmer
Aug 4, 2003
54
0
0
US
Trying to Convert '3D981CC' to Binary
0011 1101 1001 1000 0001 1100 1100

Numbers convert correctly but the letters are not right. Not sure how to convert those into binary. Any help would be greatly appreciated.



cChar = SubStr(cString,I,1)
liA = IIf(IsAlpha(cChar),Asc(cChar),Int(Val(cChar)))
For liI = 7 To 0 Step -1
lcC = lcC + Iif(Bittest(liA, liI), '1', '0')
Endfor
 
Try changing

"liA = IIf(IsAlpha(cChar),Asc(cChar),Int(Val(cChar)))"

to

"liA = IIf(IsAlpha(cChar),Asc(cChar)-55,Int(Val(cChar)))"}


mmerlinn

"Political correctness is the BADGE of a COWARD!"

 
Or you could change

"liA = IIf(IsAlpha(cChar),Asc(cChar),Int(Val(cChar)))"

to

"liA = ASC(cChar)-IIF(ASC(cChar),55,48)"

This fails for lower class alpha.




5


mmerlinn

"Political correctness is the BADGE of a COWARD!"

 
ERROR CORRECTION


Or you could change

"liA = IIf(IsAlpha(cChar),Asc(cChar),Int(Val(cChar)))"

to

"liA = ASC(cChar)-IIF(ASC(cChar)>57,55,48)"

This fails for lower class alpha.

a


mmerlinn

"Political correctness is the BADGE of a COWARD!"

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top