VB icon

BigDecToHex

Email
Submitted on: 1/18/2015 1:10:00 AM
By: Inon Henig (from psc cd)  
Level: Intermediate
User Rating: By 3 Users
Compatibility: VB 4.0 (32-bit), VB 5.0, VB 6.0, ASP (Active Server Pages) , VBA MS Access
Views: 556
 
     Converting decimal value to hexadecimal WITHOUT! using the VB functions or mod (which are limited to long data type value), therefore the function can handle BIG numbers, untill 15,000,000,000,000,000 (1.5E+16).
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
'**************************************
' Name: BigDecToHex
' Description:Converting decimal value to hexadecimal WITHOUT! using the VB functions or mod (which are limited to long data type value), therefore the function can handle BIG numbers, untill 15,000,000,000,000,000 (1.5E+16).
' By: Inon Henig (from psc cd)
'
' Inputs:decimal value
'
' Returns:hexadecimal value
'
' Side Effects:The functions might not be accurate beyond 15,000,000,000,000,000 (1.5E+16).
'**************************************

Public Function BigDecToHex(ByVal DecNum) As String
' This function is 100% accurate untill 15,000,000,000,000,000 (1.5E+16)
Dim NextHexDigit As Double
Dim HexNum As String
HexNum = ""
While DecNum <> 0
NextHexDigit = DecNum - (Int(DecNum / 16) * 16)
If NextHexDigit < 10 Then
HexNum = Chr(Asc(NextHexDigit)) & HexNum
Else
HexNum = Chr(Asc("A") + NextHexDigit - 10) & HexNum
End If
DecNum = Int(DecNum / 16)
Wend
If HexNum = "" Then HexNum = "0"
BigDecToHex = HexNum
End Function


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.