# [HELP] Conversation type

• ### Question

• Hello all, i want to know how can i convert numbers to hex.

I dont know what is the conversation method if someone knows and can help me i appreciate.

50.409.825 = 0A 41 83

99.999.975 = 14 58 55

1258.291.125 = FF FF FF (is the max)

69.036.200 = BA 88 0A

Tuesday, September 2, 2014 8:12 PM

• OK. Some more searching suggests that PES 2014 is Pro Evolution Soccer 2014 and ML is Master League (which is some sort of feature of Pro Evolution Soccer). I don't know why you thought we would know that.

It seems that you are trying to make some sort of game editor. If my guess that you need to divide the decimal number by 75 is not correct, I suggest that you ask on a forum that covers Pro Evolution Soccer, for example the PES 2014 Editing and Options Forum at www.pesgaming.com.

Tuesday, September 2, 2014 10:12 PM

### All replies

• You can use the ToString method like this:

```Dim dec As Long = 123456L
If dec >= 16 ^ 6 Then 'Test if number is greater than FF FF FF
MessageBox.Show("Invalid number")
Else
Dim hex As String = dec.ToString("X6") 'pads to 6 hex digits
hex = hex.Insert(4, " ").Insert(2, " ") 'omit if you don't need blanks between the bytes
MessageBox.Show(hex) 'Shows "01 E2 40"
End If```

• Edited by Tuesday, September 2, 2014 8:45 PM
Tuesday, September 2, 2014 8:24 PM
• And how can i make for the "dec" is the value i enter in textbox1.

If i enter in textbox1 50.409.825 and click in button1 in textbox2 will appears 0A 41 83

This:

```Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim dec As Long = TextBox1.Text
Dim hex As String = dec.ToString("X")

TextBox2.Text = hex

End Sub```

• Edited by Tuesday, September 2, 2014 8:42 PM
Tuesday, September 2, 2014 8:37 PM
• .

```Option Strict On

Public Class Form1

Dim Test1 As String = "50.409.825"
Dim Test2 As String = "99.999.975"
Dim Test3 As String = "1258.291.125"
Dim Test4 As String = "69.036.200"

Me.CenterToScreen()
End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Label1.Text = ProvideHex(Test1)
Label2.Text = ProvideHex(Test2)
Label3.Text = ProvideHex(Test3)
Label4.Text = ProvideHex(Test4)
End Sub

Private Function ProvideHex(ByRef Input As String) As String
Dim SplitTest() As String = Input.Split("."c)
Dim Output As String = Hex(SplitTest(0))
Output &= "." & Hex(SplitTest(1))
Output &= "." & Hex(SplitTest(2))
Return Output
End Function

End Class```

La vida loca

Tuesday, September 2, 2014 8:42 PM
• Hi,

I am curious how you are coming up with "0A 41 83" from a number "50.409.825" ? 50 would be 32 in hex. Also, are your numbers suppose to have commas or decimal points in them. If it is a decimal point then i can only guess that it must be a string because, numbers don`t have 2 decimal points in them.

The below code comes up with "32 199 339" for the 3 numbers "50.409.825".

```    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim num As String = "50.409.825"

Dim nums() As String = num.Split(CChar("."))
Dim converted As String = ""
For i As Integer = 0 To nums.Length - 1
If i < nums.Length - 1 Then
converted &= Hex(CInt(nums(i))) & " "
Else
converted &= Hex(CInt(nums(i)))
End If
Next
MessageBox.Show(converted) 'output is "32 199 339"
End Sub
```

If you say it can`t be done then i`ll try it

• Edited by Tuesday, September 2, 2014 8:50 PM
Tuesday, September 2, 2014 8:48 PM
• You can use the Long.TryParse method to check if a string is a valid Long and convert it.

```Dim dec As Long
If Not Long.TryParse(Me.TextBox2.Text, dec) Then
MessageBox.Show("Invalid number")
ElseIf dec >= 16 ^ 6 Then 'Test if number is greater than FF FF FF
MessageBox.Show("Number is too big")
Else
Dim hex As String = dec.ToString("X6") 'pads to 6 hex digits
hex = hex.Insert(4, " ").Insert(2, " ") 'omit if you don't need blanks between the bytes
MessageBox.Show(hex)
End If```

Tuesday, September 2, 2014 8:50 PM
• Blackwood

69036200 number is too big

This is for PES 2014.

I dont understand what "language" is because if it were decimal to hex will be:

50409825 = 3013161

but is

50409825 = 0A 41 83

• Edited by Tuesday, September 2, 2014 9:01 PM
Tuesday, September 2, 2014 8:58 PM
• Blackwood

69036200 number is too big

It is indeed too big. You said in the original post that FF FF FF is the max.
Tuesday, September 2, 2014 9:03 PM
• The following code allows 4 bytes instead of 3 bytes. If you want to work with even larger numbers, it would be helpful if you could describe the requirements in detail.

```Dim dec As Long
If Not Long.TryParse(Me.TextBox2.Text, dec) Then
MessageBox.Show("Invalid number")
ElseIf dec >= 16 ^ 8 Then 'Test if number is greater than FF FF FF FF
MessageBox.Show("Number is too big")
Else
Dim hex As String = dec.ToString("X8") 'pads to 8 hex digits
hex = hex.Insert(6, " ").Insert(4, " ").Insert(2, " ") 'omit if you don't need blanks between the bytes
MessageBox.Show(hex)
End If```

Tuesday, September 2, 2014 9:10 PM
• Blackwood

69036200 number is too big

This is for PES 2014.

I dont understand what "language" is because if it were decimal to hex will be:

50409825 = 3013161

but is

50409825 = 0A 41 83

As i said, i don`t understand how your coming up with "0A 41 83" from the 3 numbers "50.409.825". Please explain how your coming up with "0A 41 83".

If you say it can`t be done then i`ll try it

Tuesday, September 2, 2014 9:13 PM
• Blackwood

69036200 number is too big

This is for PES 2014.

I dont understand what "language" is because if it were decimal to hex will be:

50409825 = 3013161

but is

50409825 = 0A 41 83

As i said, i don`t understand how your coming up with "0A 41 83" from the 3 numbers "50.409.825". Please explain how your coming up with "0A 41 83".

If you say it can`t be done then i`ll try it

Not sure what PES 2014 is.

I don't think the 50.409.825 is three numbers in the OP's culture. I think it is one number where the thousands separator is a period rather than a comma (in other words equivalent to UK/US 50,409,825).

 I see what you mean. I never tested the OP's results. I get the same hex value as you for 50,409,825. Sorry for the confusion.
• Edited by Tuesday, September 2, 2014 9:20 PM
Tuesday, September 2, 2014 9:17 PM
• Blackwood

69036200 number is too big

This is for PES 2014.

I dont understand what "language" is because if it were decimal to hex will be:

50409825 = 3013161

but is

50409825 = 0A 41 83

Can you explain what PES 2014 is. without knowing that, I don't know what you mean by 50.409.825.
Tuesday, September 2, 2014 9:24 PM
• Is the ML money in million.

Tuesday, September 2, 2014 9:26 PM
• Is the ML money in million.

Can you explain what that means?
Tuesday, September 2, 2014 9:27 PM
• By trial and error, I found that for your first three examples, if I divide the decimal number by 75 and then convert it to hex, I get the answer you did. For example:

50409825 \ 75 is 0A 41 83 when converted to hex.

That method fails for your fourth example:

69036200 does not evenly divide by 75, and even if I ignore the remainder the result will be much smaller than BA 88 0A

In case your fourth example has a mistake, here is the code that works for the first three:

```Dim dec As Long
If Not Long.TryParse(Me.TextBox2.Text, dec) Then
MessageBox.Show("Invalid number")
Else
dec \= 75
If dec >= 16 ^ 6 Then 'test if number is greater than FF FF FF
MessageBox.Show("Number is too big")
Else
Dim hex As String = dec.ToString("X6") 'pads to 8 hex digits
hex = hex.Insert(4, " ").Insert(2, " ") 'omit if you don't need blanks between the bytes
MessageBox.Show(hex)
End If
End If```

Tuesday, September 2, 2014 9:48 PM
• Is the ML money in million.

When i search for ML money i get results for money laundering. Is that what you mean?

@ Blackwood,

Yes you may be right. I was wondering if it should be commas or a decimal point but, i still didn`t come up with "0A 41 83". I`ll let you handle this one.   8)

If you say it can`t be done then i`ll try it

Tuesday, September 2, 2014 9:49 PM
• OK. Some more searching suggests that PES 2014 is Pro Evolution Soccer 2014 and ML is Master League (which is some sort of feature of Pro Evolution Soccer). I don't know why you thought we would know that.

It seems that you are trying to make some sort of game editor. If my guess that you need to divide the decimal number by 75 is not correct, I suggest that you ask on a forum that covers Pro Evolution Soccer, for example the PES 2014 Editing and Options Forum at www.pesgaming.com.

Tuesday, September 2, 2014 10:12 PM