Using Random Strings.

daryl4356

Member
Joined
May 30, 2006
Messages
13
Programming Experience
Beginner
Hi all,

I was wondering if anyone could point me in the right direction how to do the following.

I am creating 20k different HTML pages and have got my app working to do this as I wish.

What i would like to do is randomly change a few variables each time a page is created. For example.

the webpages contain hyperlinks to for example 90 different pages. each hyperlink is in my application as a string but currently each assigned to its own variable :)eek: shocking code i know). is there a way to use my current code and randomly select one of these variables and use it's string value each time the HTML page is created? Or is there a simpler way to do this? I have no experience in arrays but have tried this but had no luck as i thought that would be a better method. Am i on the right tracks with an array?

Thanks
Daryl
 
I can hardly think there is a better and easier method than using an array or arraylist. Just randomize the item fetched by the index. Arrays would be advisable to learn if you want to do programming.
 
Thanks for your reponse. I have managed to set up an array and populated it with all the entries. The part that is confusing me is how i call it in my code.

for example my array is called Hyperlinks(105) as string.

the line of code where I want the string to appear is as follows


Do Until filecount > 10000
line9 = "<td colspan=""2"">" & Hyperlink & "</td>"
Writetofile()

I would like the Hyperlink to be replaced with this random string. I was hoping one of you could either point me to some good training material on randomizing arrays or put a little hint at what the code should be with a some left for me to work out, just to get me going.

Thanks
Daryl
 
VB.NET:
[COLOR=blue]Dim[/COLOR] autoRand [COLOR=blue]As [/COLOR][COLOR=blue]New[/COLOR] Random()
[COLOR=#0000ff]Do [SIZE=2]Until[/SIZE][/COLOR][SIZE=2] filecount > 10000[/SIZE][SIZE=2][COLOR=#008000]
[/COLOR][/SIZE][SIZE=2]line9 = [/SIZE][SIZE=2][COLOR=#800000]"<td colspan=""2"">"[/COLOR][/SIZE][SIZE=2] & Hyperlinks(autoRand.Next(105)) & [/SIZE][SIZE=2][COLOR=#800000]"</td>"
[/COLOR][/SIZE][SIZE=2]Writetofile()[/SIZE]
http://msdn2.microsoft.com/en-us/library/system.random.aspx
 
Thank you, just tried it and it works so well, thanks for also posting the article link. will have a read up on arrays in general.
 
Back
Top