15,921,250 members
1.00/5 (1 vote)
See more:
Hello, i am getting error of either too large or something else.
I want to convert Hexadecimal input into Decimal..

"2BA52820E37D077864F3CA2C1CE3174B4E57A39B6136265F973FF4734C04BB84"

What I have tried:

Public Shared Function Hex2Dec(ByVal hexstring) As String
Return Convert.ToString(Convert.ToInt64(hexstring, 16), 10)
End Function

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
TextBox3.Text = Hex2Dec(TextBox2.Text)
MessageBox.Show(TextBox3.Text.Length)
End Sub
Posted
Updated 31-Mar-20 6:55am
Ralf Meier 31-Mar-20 16:30pm
From where does this Hex-String comes ?
What is it's sense ?
The reason of my question is that no Interger-Format is able to display such a great value as it's shown above. Perhaps you don't need the conversion as discribed by you - perhaps you need something complete different as conversion-algorhythm ...
Richard MacCutchan 1-Apr-20 3:46am
All you need to do is to convert the string to its real binary value.
[no name] 3-Apr-20 1:14am
i have done that but it gives me error converting binary value to decimal. error is binary value is too long.
Richard MacCutchan 3-Apr-20 3:23am
Exactly so, you need to find a library that can generate large decimal strings.
Richard MacCutchan 3-Apr-20 12:28pm
I don't know what your code does but the result should be 257469342825821024506703013686456028765754522658832

## Solution 1

Quote:
I want to convert Hexadecimal input into Decimal..

You need to build a completely different conversion function because it is limited to 64 bits. your hex input is 64 hex => 256 bits.
I would have a look at BigInts.