[Gambas-user] Reading hex from a string socket read
danielcampos at ...282...
danielcampos at ...282...
Thu Feb 19 15:22:30 CET 2004
>Hi,
>
>I am using the socket component to make a tcp
>connnection and read some data. The data needs to be
>decoded from hex. I'm doing that with this command:
>
>Dim TwoByteCode AS Integer
>
>TwoByteCode = Val(Str$(Asc(Mid$(Buffer,1,1))) &
>Str$(Asc(Mid$(Buffer,2,1))))
>
Could you send me any example of that string? I think the conversion
you're doing does not really convert from hexadecimal format to Integer, for example:
Hexadecimal "FF" (= decimal 255)
Mid(Buffer,1,1)="F"
Asc(--previous--)=70
Str(--previous--)="70"
Val(--previous--)=70
--- With the other character:
...
Val(--previous--)=70
Then you use "&" operator so the final result is:
"7070" and then you assign it to a Integer so it is -7070-
???
I don't understand very well...
Regards,
Daniel Campos
-------------------------------------------------------------
NetCourrier, votre bureau virtuel sur Internet : Mail, Agenda, Clubs, Toolbar...
Web/Wap : www.netcourrier.com
Téléphone/Fax : 08 92 69 00 21 (0,34 TTC/min)
Minitel: 3615 NETCOURRIER (0,16 TTC/min)
More information about the User
mailing list