# Thread: How To convert Hex to Dec in VB6.0?

1. Hi Guys,

I need to know how to convert Hexidecimal into decimal in Vb6.0
I am receiving data from my comm port in Text and there are some values that are in Hex. but i need the numeric value of them.

is that a command of module that i can use to do this?
let me know.

EL.

2. I don't think VB has a built-in hex to dec function

Here's one I just knocked-up:

Code:
```Public Function HextoDec(HexNum As String) As Long
Dim lngOut As Long
Dim i As Integer
Dim c As Integer

For i = 1 To Len(HexNum)
c = Asc(UCase(Mid(HexNum, i, 1)))
Select Case c

Case 65 To 70
lngOut = lngOut + ((c - 55) * 16 ^ (Len(HexNum) - i))

Case 48 To 57
lngOut = lngOut + ((c - 48) * 16 ^ (Len(HexNum) - i))

Case Else

End Select
Next i
HextoDec = lngOut
End Function```

3. ## Re: How To convert Hex to Dec in VB6.0?

More simple:

DecNumber& = CLng("&H" & HexNum\$)

4. ## Re: How To convert Hex to Dec in VB6.0?

Wow - and this thread is over 10 years old.

5. ## Re: How To convert Hex to Dec in VB6.0?

Originally Posted by szlamany
Wow - and this thread is over 10 years old.

Because I search for this code and lost time, the two threads I answer are old but first in the search of google for this conversion, and for other people not lost time, the last instruction is the best, I test various, and this is simple, fast and totally operative...

Is the reason, for people that search this conversion, have fast and simple and good solution...

Pd: Many persons use VB6, is old, but very usseful, I for example have a program in virtual machine - in a oracle sun virtualbox portable - that I sell, and in the virtual machine have a Windows XP 32 bits, and for this operative system, vb6 is fast and a good solution... And in the virtual machine my program run without changes, worked for decades is possible, and I not lost time in the changes of different versions of windows and changes and craps of microsoft...

Also in virtualbox machine is possible for my sell the program for mac and for linux, good solution without need to create 3 programs... One for each system...

One of the big problems of the programation is that is impossible arrive to a be master master master because each little time, changes, changes, changes, and the programmer need to create a good software of any thing, not lost your time in known new codes all the time...

I with the solution of virtualbox portable, is possible for me put all my time in make a better program, not lose all my time in known the stupids and always changes of microsoft...

6. ## Re: How To convert Hex to Dec in VB6.0?

It was very useful to me. I still work a lot with VB6 and do some things the old fashioned way.

7. ## Re: How To convert Hex to Dec in VB6.0?

I enjoy your advice even today, end of 2017, CDbl("&H" & "ABCDE")

8. ## Re: How To convert Hex to Dec in VB6.0?

In fact, VB6 is not that old fashioned: it is similar to VBA in Excel, Word, and so on.
Besides, it is much easier than VB.NET.
I don't like VB6, I love it!

9. ## Re: How To convert Hex to Dec in VB6.0?

Hello

Beste Kees

my email <removed by moderator>

A.U.B my email contac

10. ## Re: How To convert Hex to Dec in VB6.0?

Do not put an email into a post. There are too many bots cruising the web ready to gather up those addresses and spam you incessantly.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

Featured