VB.net XOR operation using HEX

I want to calculate a BCC XOR in hex using Visual Basic 2012 for the following String: H enter * in hex (48 0D 2A) using the following rule: Step 1. BCCXOR = 00h BCCXOR = 00 Step 2. BCCXOR = BCCXOR xor 48 BCCXOR xor first character - result BCCXOR = 48h Step 3. BCCXOR = BCCXOR xor 0D BCCXOR xor second character - result BCCXOR = 44h Step 4. BCCXOR = BCCXOR xor 2A BCCXOR xor third character - result BCCXOR = 6Fh

My code is:

    Dim BCCXOR As Integer = &H0
    For i As Integer = 0 To TextBox1.TextLength - 1
        BCCXOR = (BCCXOR) Xor Conversion.Hex(Strings.Asc(TextBox1.Text.Substring(i, i + 1).ToString()))
    Next
    BCCXOR = BCCXOR Xor Hex(&HD)
    BCCXOR = BCCXOR Xor Hex(&H2A)
    TextBox2.Text = BCCXOR

My problem is that I receive an error message when I'm trying to calculate BCCXOR xor 0D I receive an error like: Conversion from string "D" to type 'Long' is not valid.

Answers


The Hex fonction converts a number to a string. I don't think this is what you want. Just remove the fonction call and it should work.

BCCXOR = BCCXOR Xor &HD
BCCXOR = BCCXOR Xor &H2A

Need Your Help

vertical centre modal with aspect 16:9

html css

I have a modal popup that I have an aspect ratio of 16:9.

How best to store game config variables in java

java

I'm writing a small java game and am storing global game settings in a class structure like the one below: