Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
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...
please help me.....................
Posted 14-Nov-12 1:08am
Edited 14-Nov-12 1:15am
__TR__28.9K
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
v2
Comments
chandinig at 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 at 15-Nov-12 11:44am
   
i think those links will help you to convert it..
chandinig at 16-Nov-12 4:07am
   
sorry i didn't get can you give me simple vb code for hexa decimal value for 12.340............
please....................
ridoy at 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 at 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...
please help me
chandinig at 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 at 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..
http://www.dreamincode.net/forums/topic/57502-convert-from-decimal-to-hexadecimal/
chandinig at 18-Nov-12 23:44pm
   
when ever used hex$(12.5) it gives c only so not for 0.5 please help me...............
chandinig at 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
 
End Class please help me for 32 bit binary number
ridoy at 21-Nov-12 7:40am
   
http://social.msdn.microsoft.com/Forums/en/vbgeneral/thread/b1782944-9263-4813-a5d3-ca8c5fe04b63
chandinig at 24-Nov-12 0:34am
   
I got solution thanks for response

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 265
1 _Amy 235
2 Peter Leow 205
3 Andreas Gieriet 180
4 Shmuel Zang 120
0 OriginalGriff 7,540
1 Sergey Alexandrovich Kryukov 6,412
2 Maciej Los 3,849
3 Peter Leow 3,653
4 CHill60 2,712


Advertise | Privacy | Mobile
Web02 | 2.8.140721.1 | Last Updated 14 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100