English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Hi Im currently making an application in Visual Basic.Net and I want it to display 2 random bits of text but I want to have a set list that I can import into my resources and use so say if it was a food program (which its not)
When the user clicks the button the program gets 2 random lines of text from a file in my resoruces and changes the .text property of my labels.

Can this be done?
If so please give links or code please remeber its Visual Basic.Net

2007-02-27 05:17:46 · 6 answers · asked by sbraidley 3 in Computers & Internet Programming & Design

If possible please give an emxample soruce code so I can look at it just give a url for it or email it to me at sbraidley@yahoo.co.uk

2007-02-27 06:16:17 · update #1

6 answers

There is a RAND() function available in VB that you can use to grab a random number. You'd open the text file and loop through lines until you hit line number (random).

Another method I use sometimes is to get the time from the NOW() function and use the seconds. So if the time is 10:56:13 AM it would get me the 13th line in the text file.

hope that helps

2007-02-27 05:39:17 · answer #1 · answered by rod 6 · 1 0

Look up the random function, you can limit the range it generates numbers between. You can then use the random number to grab a line form a text file or a record from a data table with the corresponding number. Then of course just set your label or textbox to equal the string you just grabbed.

2007-02-27 06:09:00 · answer #2 · answered by joec_11 3 · 0 0

It sure is possible. There's a Random class in VB that can generate your random indexes into arrays of text items. From there, you just need a mechanism to store the random text arrays, and to set the text labels when two are chosen.

2007-02-27 06:10:03 · answer #3 · answered by Pfo 7 · 0 0

It's probably easiest to dump your resource file into a string array, and then use the Random function to pick a random index within the array to display.

2007-02-27 08:10:29 · answer #4 · answered by Kryzchek 4 · 0 0

I do sense badly for the boys who attempt very complicated to ward off having lustful strategies, while they are bombarded with scantily clad females. It certainly isn't honest. you be responsive to, i do no longer think of that that's achieveable, yet God is conscious your heart, and he's merciful and in simple terms. He is conscious which you do no longer intend on having strategies like that, although this is not any longer 22 advert anymore. Heck, this is not any longer 1952 anymore - the sexual revolution has pervaded North and South u.s., Europe, Asia, Australia, and Africa. in recent times, in case you prefer to ward off seeing all that pores and skin, you may desire to pass to the Yukon! you're doing all your perfect. If it helps any, think of the gorgeous lady in front of you with the flu. She in simple terms finished retching and has bleary eyes and messy hair. Or faux she in simple terms did something fairly gross. Use your mind's eye to make her seem disgusting, fairly of what your mind's eye in many cases could do in case you probably did no longer attempt to provide up it. :o)

2016-10-02 02:02:29 · answer #5 · answered by ? 4 · 0 0

check out http://www.pscode.com for great sample codes.

2007-02-27 07:39:03 · answer #6 · answered by Richard H 7 · 0 1

fedest.com, questions and answers