How-To... - Convert Hexadecimal to Long

Converting Hex to Long is another simple conversion using Visual Basic's Val Function. The code takes the contents of txtHex, converts it to Hex and then stores it in txtConversion :-

'Find the value of the Hex number using Val.
'Using Val(txthex) would not convert the
'letters that are used in Hex.
'
'Putting &H and & at the beginning and end,
'Val then converts the letters.
'Type in F and the answer will be 15
'Type in 1F and the answer will be 31...

txtConversion = Val("&H" & txtHex & "&")


This site is Copyright © 1999 of David Cowan. VB How-To, Dodgesoft and DodgeSoft Productions is Copyright © 1999 of David Cowan. Source-code and programs are copyright of their respective owners. For a messageboard, click here