Help translating one Excel VBA line of code

BlitzMax Forums/BlitzMax Programming/Help translating one Excel VBA line of code

Nennig(Posted 2016) [#1]
Hi there,

I am trying to port this piece of code from Excel VBA to Blitzmax but can't figure it out.

Anybody who could help me?

Thank you


        For intX = 1 To Len(strText) Step 2
                
                '???????
                Mid(strText, (intX + 1) / 2, 1) = Chr(Val("&H" & Mid(strText, intX, 2)))

        Next 




grable(Posted 2016) [#2]
Knowing what it takes as input would help, but il take stab anyway ;)

It looks to read 2 characters as Hex, converts its value to a character which it writes to the same string.
Since blitzmax has immutable strings this wont work directly, but it writes it to the beginning of the string so creating a new one should suffice.
Local s:String = "414243"
Local r:String
For Local i:Int = 0 Until s.Length Step 2
	r :+ Chr( ("$" + s[i .. i + 2]).ToInt())
Next
Print r



Nennig(Posted 2016) [#3]
Thank you so much for your help grable!

The context is the following. I found a RC4 encryption algorithm implementation in Excel
and wanted to be sure to generate the same encryption in Blitmax because I use Excel to generate my data in the first place.

I have no idea what I'm doing but I'm learning ;-)

Cheers