0

I'm shuffling a string called STR in VB using:

For K = 1 To Len(Str)
    Sk = Sk + Asc(Mid$(Str, K, 1))
Next K

Rnd(-1)
Randomize(Sk)

For K = 1 To Len(Str)
    RndPos = 1 + Fix(Len(Str) * Rnd)
    ' SWAP Chars
    Tmp = Mid$(Str, K, 1)
    Mid$(Str, K, 1) = Mid$(Str, RndPos, 1)
    Mid$(Str, RndPos, 1) = Tmp
Next K

I would like to unscramble it in C code on AIX, i can't however find the equivalent of Randomize(double) from VBMATH.

Is there an easy way around it ?

I know that i can seed C's rand() function with srand, but i'm stuck after that.. all the online resources are for C#.

Any help will be appreciated !

Cheers.

Visual Vincent
  • 18,045
  • 5
  • 28
  • 75
M Aoun
  • 11
  • 5
  • Is that really VB.Net ? it looks so "VB6 (or even VB4)-ish". Also a duplicate (or rather where the answer is) of http://stackoverflow.com/questions/822323/how-to-generate-a-random-number-in-c – Sehnsucht Oct 28 '16 at 13:00
  • "I would like to unscramble it in C " but you would have to use the *exact same* PRNG. – Weather Vane Oct 28 '16 at 13:01

0 Answers0