• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 181
  • Last Modified:

data type conversion

how to convert a string of ascii hexadecimal values into unsigned long integer in Visual Basic?
0
purushotham
Asked:
purushotham
1 Solution
 
DalinCommented:
purushotham,
You should be able to get it with the combination of cLng, Chr, and ASC function.
Regards
Dalin
0
 
swiltCommented:
This should give the right answers

Public Function ConvHex2Dec(ByVal sInp As String) As Long
    Dim nRet As Long
   
    If Len(sInp) > 8 Then
        MsgBox "Too long"
    Else
        nRet = Val("&H" & sInp)
        If nRet < 0 And Len(sInp) < 8 Then
            While Len(sInp) < 7
                sInp = "0" & sInp
            Wend
            nRet = Val("&H8" & sInp) And &H7FFFFFFF
        End If
    End If
   
    ConvHex2Dec = nRet
End Function
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now