Hi 2 all,
I have a String that contains Hex Value
Dim hexvalues As String = "AABBCC"
I need to make this addition: AA + BB + CC = 231 (dec: 561)
In a bit word i need a function that it calc Hex Values.
How can i do !
Hi 2 all,
I have a String that contains Hex Value
Dim hexvalues As String = "AABBCC"
I need to make this addition: AA + BB + CC = 231 (dec: 561)
In a bit word i need a function that it calc Hex Values.
How can i do !
Working with Hex Value
gvraovc
Hi i solved with my code,
my error was to assing the wrong variable, i assigned it the variable i and i needed variable result
KarimRadi
Dim
MyInteger As Integer = Convert.ToInt32("AA", 16)Debug.Print(myInteger.ToString) = 170
adm10
But i had to take the HexString in couple of two char
It mean if i have "AABBCC"
They are 3 Hex Values:
So i have to make a Substring too. Am i saying right
This is my code:
Dim filex As String = "300000110000002F000900000" & Seem() & Record() & Offset() & "0001" & Value() Dim x As String Dim result As Integer Do While filex.Length >= 1 ' Inner loop.x = filex.Substring(0, 2)
Dim y As Integer = Convert.ToInt32(x, 16)result = result + y
filex = filex.Remove(0, 2)
Exit Do Loop Dim risultato As String = Hex(result) Dim checksum As StreamWriterchecksum = File.AppendText(SaveFileDialog1.FileName)
checksum.Write(risultato)
checksum.Close()
What do you think about my code
Grotius
vitagreen
Ok!
I tested my function and it return always a Wrong Value :(
So do you have any ideas or any snippets
BrianXXX
This exactly what i did, but no lucky it didn't work :(
' Calcolo Checksum Dim filex As String = "AABB" Dim temp As Integer Dim i As Integer For x As Integer = 0 To filex.Length / 2 - 1 Dim rex As String = filex.Substring(0, 2)temp = Convert.ToInt32(rex, 16)
i = i + temp
filex = filex.Remove(0, 2)
Next 'FineCalcolo Checksum Dim risultato = Hex(i)The matter is that it doesn't seem working correctly with Substring
Klaxas
Hi,
You can replace the line highlighted in yellow below with this .>> myValue=&HAA + &HBB + &HCC
'to deal with HEX values put &H before the characters.
Enjoy!!
Use the same idea to subtract or integer division or multiply etc. E.G.
myValue = &HAB * &HCB
myValue= &HFAB - &HEAF
myValue= &HFF \ &H8
Regards,
S_DS
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim myValue As Int64myValue =999999999999999999
Dim result As Stringresult = toHex(myValue)
TextBox1.Text = result
End Sub Function toHex(ByVal myInt As Int64) As String Dim res As String Dim Int1, Int2, lg, index As Int64Int1 = myInt
Int2 = myInt
Trylg = Math.Log(Int1) \ Math.Log(16)
For index = lg To 0 Step -1Int2 = Int1 \ (Math.Pow(16, index))
Int1 = Int1 - (Int2 * (myPow(16, index)))
Select Case Int2 Case 0 To 9res = res +
CStr(Int2) Case 10res = res + "A"
Case 11res = res + "B"
Case 12res = res + "C"
Case 13res = res + "D"
Case 14res = res + "E"
Case 15res = res + "F"
Case Is >= 16res = toHex(Int2)
End Select Next Return resCatch ex As Exception
MsgBox(ex.ToString)
End Try
End Function Function myPow(ByVal num1 As Int64, ByVal num2 As Int64) As Int64 Dim n1, n2 As Int64n1 = num1 : n2 = num2
Dim index, result As Int64 For index = 1 To n2 - 1n1 = n1 * num1
Nextresult = n1
Return n1 End FunctionShadi_05
I solved creating a function.
My code above is completely wrong. :)
BilalShouman
"I have a String that contains Hex Value"
Strings do not contain hex values. Strings contain characters. The Characters may represent binary numbers described in a hex radix (base 16). I think these distinctions are important to remember.
Convert the strings to binary and do with them as you may and then convert them to the radix in which you want them displayed.