Not a Member Yet,
Click here to Register

ID: 378
Viewed: 3273
Added: Aug 19, 2002
Version:
Snippet uploaded by: snippet
Written By: Unknown
Demo: Sorry, no demo



User Rated at: 0 Stars
Rate This:

Thank you for your vote. Please wait...

It appears you already voted for this snippet

It appears your vote value was empty

Can convert Hex to Decimal and Deciaml to Hex and converts html Hex to VB RGB.

Highlight all by clicking in box
<!---Declaration--->
none

Highlight All
<!---Code--->
'To convert 64 hex to decimal: 

'code:

Private Sub Command1_Click()
MsgBox HexToDec(64)
End Sub

Private Function HexToDec(ByVal Hex As Long) As Long
HexToDec = CLng("&h" & Hex)
End Function


'****************************************************************************************************

'To convert 134 decimal to hex:

'code:

MsgBox Hex$(134)

'********************************************************************

'Converting html-color to VB-colorThe value given to HexToRGB function must be Hex(value).

'code:


Function HexToRGB (Text As String) As Long
HexSwap(Text)
If Len(Text) <> 6 Then Exit Function
HexToRGB = CLng("&H" & Text)
End Function

Sub HexSwap(ByRef Text As String)
If Len(Text) = 6 Then
Text = Right(Text, 2) & Mid(Text, 3, 2) & Left(Text, 2)
'I hope that line has no error
ElseIf Len(Text) = 5 Then
Text = Right(Text, 2) & Mid(Text, 2, 2) & "0" & Left(Text, 1)
ElseIf Len(Text) = 4 Then
Text = Right(Text, 2) & Left(Text, 2) & "00"
ElseIf Len(Text) = 3 Then
Text = Right(Text, 2) & "0" & Left(Text, 1) & "00"
ElseIf Len(Text) = 2 Then
Text = Text & "0000"
ElseIf Len(Text) = 1 Then
Text = "0" & Text & "0000"
Else
Text = ""
End If
End Sub;


No Comments to show

Please completely fill out the form below if you want to review this snippet. All reviews are subject to validation.


Replying to a Comment...


Adding your comment. Please wait...

Thanks for adding your comment!. After further review it will be added.

There was a problem adding your comment. Please try again.

Please complete all the fields in the form before sending.

© 2002 - 2024 snippetlibrary.com All Rights Reserved. Conditions
Do NOT follow this link or you will be banned from the site!