[Gambas-user] Reading hex from a string socket read

ron ronstk at ...239...
Thu Feb 19 17:31:45 CET 2004


On Thursday 19 February 2004 15:01, adam krell wrote:
> 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))))
>
> Is there a more efficient way to do this?  If I am
> decoding a long string of data this can really slow
> down the program.
>
> Thanks,
>
> Adam
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Mail SpamGuard - Read only the mail you want.
> http://antispam.yahoo.com/tools
>
>
> -------------------------------------------------------
> SF.Net is sponsored by: Speed Start Your Linux Apps Now.
> Build and deploy apps & Web services for Linux with
> a free DVD software kit from IBM. Click Now!
> http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user

from the gambas-help decimal to hex

decimal to hex
------------
PRINT Hex$(1972)
=> 7B4
PRINT Hex$(1972, 8)
=> 000007B4

Reverse hex o decimal
-------------------
DIM sHex AS String
sHex= "&H" & "A2" & "&" '<-- A2 is you hex string
PRINT "Val('&HA2&')=", Val(sHex)

Any way Gambas knows &HA1& for hexadecimal presentation

Ron





More information about the User mailing list