jeudi 20 juin 2019

vba get random with string as seed

I'm working under MS-Visio 2010 in VBA (not an expert) and I want to generate a random number (several numbers would be even better) based on a string as seed.

I know that Rnd(seed) with seed as a negative number exists. However, I don't know about any random generator with a string seed. Maybe some kind of hash function with a number as result ?

I'd like something like :

print function("abc")
45
print function("xyz abc-5")
86
print function("abc")
45

with spaces, symbols and numbers support when inside the seed string.

I may see a workaround by converting each character to some ascii number corresponding and somehow using this big number as seed with Rnd but it definitely feels far-fetched. Do anyone knows of a fancier way of doing so ?




Aucun commentaire:

Enregistrer un commentaire