|
-
Oct 7th, 2002, 02:04 PM
#1
Thread Starter
Hyperactive Member
Hex -> Integer, How to
How do I convert Hex to an Integer?
53323737 15 743 313402 05 740313063. 17 15 4150 743 313402 05 140393403437 5203 743 30210.

-
Oct 7th, 2002, 02:06 PM
#2
So Unbanned
val("&HFF") = 255
so val("&h" & hex_val)
-
Oct 7th, 2002, 02:16 PM
#3
Thread Starter
Hyperactive Member
You missed the point DigitalError. The thing i'm trying to find is:
VB Code:
Function ConvertHex(Input as String) as Integer
Output = Something(Input)
ConvertHex = Output
End Function
53323737 15 743 313402 05 740313063. 17 15 4150 743 313402 05 140393403437 5203 743 30210.

-
Oct 7th, 2002, 02:19 PM
#4
PowerPoster
If you are sure that conversion will remain within Integer bounds, then use the CInt function, otherwise use the CLng function.
-
Oct 7th, 2002, 02:28 PM
#5
Thread Starter
Hyperactive Member
Those functions do not work with STRING type Hex.
The hex I am using is not the "&H??" its more like a string type.
eg.
VB Code:
i = ConvertHex("FF")
'i = 255
53323737 15 743 313402 05 740313063. 17 15 4150 743 313402 05 140393403437 5203 743 30210.

-
Oct 7th, 2002, 02:35 PM
#6
PowerPoster
Why don't you append the &H at the begining?
VB Code:
Private Function ConvertHex(ByRef HexValue As String) As Long
If Not UCase(Left$(HexValue, 2)) = "H&" Then HexValue = "&H" & HexValue
ConvertHex = CLng(HexValue)
End Function
-
Oct 7th, 2002, 02:48 PM
#7
Thread Starter
Hyperactive Member
Because wrighting filenames.
eg.
Filename.002
Filename.0BF
VB Code:
'ID = 0 to 4096
iHex = ConvertToHex(ID)
OpenAsTextStream(Filename & iHex, blah, blah) 'iHex = number after conversion from i
'Then:
ID=ConvertToI(Right(Filename, 3))
'^^^ this is what i mean.
Long Story Short. Dont ask why the hell I'm doing this, because it is too hard & long to explain.
53323737 15 743 313402 05 740313063. 17 15 4150 743 313402 05 140393403437 5203 743 30210.

-
Oct 7th, 2002, 02:53 PM
#8
Thread Starter
Hyperactive Member
Here this will help:
VB Code:
Filename = User_ID.1AF 'Sample File
ID = ConvertToInteger(Right(Filename, 3) 'Converts the"1AF" to an Integer.
ID = ?
53323737 15 743 313402 05 740313063. 17 15 4150 743 313402 05 140393403437 5203 743 30210.

-
Oct 7th, 2002, 02:56 PM
#9
PowerPoster
VB Code:
ID = ConvertToInteger("&H" & Right(Filename, 3)
And then In ConvertToInteger function use CInt.
-
Oct 7th, 2002, 03:01 PM
#10
Thread Starter
Hyperactive Member
I'll post the rest of what the hell I'm doing tomarrow. But that works thanx.
53323737 15 743 313402 05 740313063. 17 15 4150 743 313402 05 140393403437 5203 743 30210.

-
Oct 7th, 2002, 04:12 PM
#11
Banned
You add the &H in the conversion function, from the's original value.
Duh.
here:
VB Code:
Function HexToInt(byval HexDat as string) as Integer
HexIoInt = val("&h" & HexDat)
End Function
To use:
i HexToInt("FF")
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|