Reputation: 31
I'm making a random hexadecimal generator is it possible in visual basic to make a code that randomly generates number and letters together? How would you do it? I'm really lost. I'd like to randomly generate a 2 string hexadecimal including numbers and letters or sometimes output just either a letter or a string.
I'd like to randomly generate for example "01", "A" , "AF", "B2", "8", "0F" etc
Upvotes: 0
Views: 86
Reputation: 29
You could also use an algorithm that first got a random number 1 (1 for the values such as "8")or 2 (0 or 1 if index starts at 0 (i haven't done BASIC in a while)). Then generate a random index from a list. Put them together and you got your string.
Upvotes: 0
Reputation: 1808
You can generate a random integer (as the usual base 10) using System.Random
, and then convert the Base 10 integer into a Base 16 string reasonably easily:
Convert.ToString(myNumber, 16)
Upvotes: 1