VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Converts a hex-string to an integer

by XricardoX (1 Submission)
Category: Math/Dates
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sat 23rd June 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Converts a hex-string to an integer

API Declarations


Dim a, c, d As Integer


Rate Converts a hex-string to an integer



'We'll start by getting every character out of the
'hex-string seperatly
For a = 1 To Len(hexx)
b = Mid$(hexx, a, 1)
'Then we'll change the hex-strings "A" to "F" by "10" to "15"
If ucase(b) = "A" Then b = "10"
If ucase(b) = "B" Then b = "11"
If ucase(b) = "C" Then b = "12"
If ucase(b) = "D" Then b = "13"
If ucase(b) = "E" Then b = "14"
If ucase(b) = "F" Then b = "15"
'and put the integer value in c
c = Val(b)
'this line converts every character from the hex-string to
'an integer value, and counts them together
d = d + (c * (16 ^ (Len(hexx) - a)))
Next a
hex_to_int = d 'assign the function to d
End Function

Download this snippet    Add to My Saved Code

Converts a hex-string to an integer Comments

No comments have been posted about Converts a hex-string to an integer. Why not be the first to post a comment about Converts a hex-string to an integer.

Post your comment

Subject:
Message:
0/1000 characters