11,934,380 members (31,058 online)
Rate this:
See more:
Hi all,
Can you help me how to convert double value to hexa decimal values in vb.net...
my actual code is
```Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Val As Double
Val=TextBox1.text```
in this how we convert val(double) to hexa decimal...
Posted 14-Nov-12 2:08am
Edited 14-Nov-12 2:15am
__TR__29K
v2

Rate this:

## Solution 1

v2
chandinig 15-Nov-12 2:05am

thanks for response,
actually my number is 12.5 so how to convert this one to hexa decimal number
ridoy 15-Nov-12 11:44am

chandinig 16-Nov-12 4:07am

sorry i didn't get can you give me simple vb code for hexa decimal value for 12.340............
ridoy 16-Nov-12 4:19am

try with..
Dim D As Double = 12.340
Dim B() As Byte = BitConverter.GetBytes(D)
Dim SB As New System.Text.StringBuilder(B.Length)
For I As Integer = 0 To B.Length - 1
SB.Append(Hex(B(I)))
Next
Dim S As String = SB.ToString

or..

Dim D As Double = 12.340
Dim I64 As Int64 = BitConverter.DoubleToInt64Bits(D)
Dim S As String = Hex(I64)
chandinig 16-Nov-12 5:25am

For first program i get AE47E17A14AE2840 but my exact need is for 12.340 i want get 70A44145 hexa decimal value...
chandinig 16-Nov-12 23:21pm

what my exact problem is i want to get 8 digit hexa decimal value for 12.340(floating or double)
ridoy 17-Nov-12 1:34am

We don't code for yourself.you need to try it yourself,follow my 1st link carefully,your answer is there.If it not work then try with CType function.Here is more about it..
http://www.java-samples.com/showtutorial.php?tutorialid=961
Also look here..
chandinig 18-Nov-12 23:44pm

chandinig 21-Nov-12 1:58am

Hi what my exact problem is i want convert float(single) value to 32bit binary number.
i have code but it is for 64 bit binary number
code is
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim number As Double = 12.34
Dim numberAsLong As Integer = BitConverter.DoubleToInt64Bits(number)
Dim numberInBinary As String = Convert.ToString(numberAsLong, 2)
TextBox1.Text = numberInBinary

End Sub

ridoy 21-Nov-12 7:40am

chandinig 24-Nov-12 0:34am

I got solution thanks for response

Top Experts
Last 24hrsThis month
 George Jonsson 440 OriginalGriff 185 Dave Kreskowiak 183 pwasser 170 BillWoodruff 168
 George Jonsson 350 OriginalGriff 175 Dave Kreskowiak 145 Richard Deeming 120 pwasser 120