Two possibilities:
Sub HexTest()
Dim hex1 As String
Dim dec1 As Integer
hex1 = "F"
dec1 = "&h" & hex1
MsgBox dec1
hex1 = "ff"
MsgBox hx2dc(hex1)
End Sub
Function hx2dc(s$) As Long
hx2dc = "&h" & s$
End Function
Gerrit van Stempvoort wrote:
Hello,
To be able to work with hex numbers you have to install the Add-In "Analysis
Toolpack" first (Tools Menu, Add-Ins and check the Analysis Toolpack
checkbox).
You may need the Office Installation CD to do this.
When this is done you find a new function category (Insert Function) with
the name "Engineering". In this function category you fine several functions
like Hex2Dec.
In VB it seems to be more complicated.
The sub:
Dim Dec1 As Long
Dec1 = "&hF"
End Sub
will return the value 15 for Dec1, but if you use a variable input like in
this sub:
Dim Hex1 As String
Dim Dec1 As Long
Sub HexTest()
Hex1 = "F"
Dec1 = "&h(Hex1)"
End Sub
Then I get a "type mismatch" error.
So if someone can help me how to avoid this problem I wil be very grateful.
Thanks beforehand,
Gerrit
In EXCEL you have to install the
"Tom" schreef in bericht
om...
How do I convert a hex byte into an ascii character? I'll take an
excel formula or VB code. Either way would be fine. I could not find
an excel function to do this. I appreciate any help submitted. Thank
you.
tom