home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.visual.basic      MS Visual Basic discussions, NOT dot-net      10,840 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 10,734 of 10,840   
   Raoul Watson to Antony Clements   
   Re: hex to byte   
   29 Mar 09 22:05:47   
   
   From: WatsonR@IntelligenCIA.com   
      
   Antony Clements wrote:   
   > "Raoul Watson"  wrote in message   
   > news:IcNzl.387$Q52.377@nwrddc02.gnilink.net...   
   >> Antony Clements wrote:   
   >>> I have a hex string consisting of 64 characters, and I want to take every   
   >>> two characters and convert them to their respective byte value (eg FF =   
   >>> 255). Is there a fast and eficient way of doing this, or does it have to   
   >>> be done manually?   
   >> I would use the VB internal ability to convert hex:   
   >>   
   >> Private Function Hex2Dec(h$) As Integer   
   >>   h$ = "&H" & h$   
   >>   Hex2Dec = Val(h$)   
   >> End Function   
   >>   
   >> So you'll get 255 when you pass "FF"   
   >   
   > Thanks, I didn't know there was an internal function. This would work fine   
   > for integers, but what if the value is only a single byte, or a long, or a   
   > double? Would this also work for turning a value into a hex value?   
   >   
   > In another part of my code I am taking a integral double (no decimal points)   
   > and converting it to hex, manipulating the hex value and converting it back,   
   > it's all very resource consuming.   
   >   
   >   
   Use the HEX function to go the other way. Byte, long, doesn't matter. Do   
   it it a byte at a time..   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca