Solved

data type conversion

Posted on 1998-10-05
2
166 Views
Last Modified: 2010-04-30
how to convert a string of ascii hexadecimal values into unsigned long integer in Visual Basic?
0
Comment
Question by:purushotham
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 9

Expert Comment

by:Dalin
ID: 1438171
purushotham,
You should be able to get it with the combination of cLng, Chr, and ASC function.
Regards
Dalin
0
 
LVL 2

Accepted Solution

by:
swilt earned 150 total points
ID: 1438172
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

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month10 days, 19 hours left to enroll

628 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question