|
-
Jun 8th, 2000, 04:34 AM
#1
Thread Starter
Lively Member
Can someone tell me how to convert an Hexidecimal number to a Decimal number please, as i want to convert a hexadecimal colour of say a form to that of a decimal one...any1 know how?
Mag-Net's Home
Visual Studio 6-Enterprise - SP4
ICQ: 35519773
Have Fun 
-
Jun 8th, 2000, 04:48 AM
#2
transcendental analytic
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jun 8th, 2000, 05:33 AM
#3
transcendental analytic
Ok, that needed some maintenance, now you can use up to base 201
Code:
' - - - - - - - K E D A M A N S C O D E- - - - - - -30.5.00 ( updated 9.6.00 )
' Base mod decimal converters
'IE bin 2 dec
' Base2dec("1234",2)
' oct 2 bin
' dec2base(Base2dec("1234",8),2)
'trin 2 hex
' dec2base(Base2dec("1234",3),16)
Function Base2Dec(val$, base%): Dim n%, a() As Byte
a = StrConv(UCase(val), vbFromUnicode)
For n = 1 To Len(val)
Base2Dec = CDec(Base2Dec + (a(n - 1) - 48 + 7 * (a(n - 1) > 64)) * base ^ (Len(val) - n))
Next n
End Function
Function Dec2Base$(val, base%): Dim n%, s
For n = 0 To 100
s = Int(val / base ^ n)
If s = 0 Then Exit For
s = s - Int(s / base) * base 's mod base
Dec2Base = Chr(s + 48 - 7 * (s > 9)) & Dec2Base
Next n
End Function
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jun 8th, 2000, 07:11 AM
#4
Junior Member
here:
Function HexToDec(TheHex As String) As Long
HexToDec = CLng("&H" & TheHex)
End Function
-
Jun 8th, 2000, 02:48 PM
#5
Hyperactive Member
Hello Mag-Net,
Try this source:
Private Sub Command1_Click()
Dim Tabel As String
Dim Temp, N As Integer
Dim Answer As Long
Answer = 0
Tabel = "0123456789ABCDEF"
'if you want to create Octal to decimal: Tabel = "01234567"
Text1.Text = UCase(Text1.Text)
For N = 1 To Len(Text1.Text)
Temp = InStr(1, Tabel, Mid(Text1.Text, N, 1)) - 1
Answer = Answer + (16 ^ (Len(Text1.Text) - N)) * Temp
Next N
MsgBox Answer
End Sub
Good luck,
Michelle.
[Edited by michelle on 06-09-2000 at 03:55 AM]
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
|