Decimal To Hexadecimal

This algorithm converts decimal numbers to hexadecimal numbers.



									Public Shared Function DecimalToHexadecimal(dec As Integer) As String
	If dec < 1 Then Return "0"

	Dim hex As Integer = dec
	Dim hexStr As String = String.Empty

	While dec > 0
		hex = dec Mod 16

		If hex < 10 Then
			hexStr = hexStr.Insert(0, Convert.ToChar(hex + 48).ToString())
		Else
			hexStr = hexStr.Insert(0, Convert.ToChar(hex + 55).ToString())
		End If

		dec = Int(dec / 16)
	End While

	Return hexStr
End Function
								


Example

									Dim data = 484879
Dim value = DecimalToHexadecimal(data)
								


Output

									7660F