Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Randomizing strings

Status
Not open for further replies.

Crazier

Programmer
Apr 24, 2002
10
US
I can't seem to get this program to work I am not too familiar with randomizing with strings. I have done it several times with numbers. How can I make this work.

Dim Answers$ (1 to 8)
RANDOMIZE -TIMER

CLS

OPEN "reply.txt" FOR OUTPUT AS #1
WRITE #1 Yes
WRITE #1 seldom
WRITE #1 maybe
WRITE #1 never
WRITE #1 always
WRITE #1 sometimes
WRITE #1 no
WRITE #1 not anytime soon

CLOSE #1

OPEN "reply.txt" FOR OUTPUT AS #1

count = 0
DO WHILE NOT EOF(1)
count = count + 1
Answers$ = INT(RND * count) + 1
LOOP
CLOSE #1
END
I'd appreciate any suggestions.
Thanks
 
thsi question is not very clear, but I think that I can help you.
first look up the DIM statement
then look at this example.

DIM card$(52) 'a standard deck of cards
'here you would represent each card with the LET statement
'**********this draws a random card****************
x = INT(RND *52)+1
newcard = card$(x)
 
Do you know how to do it with strings. I need responses to pop up at random instead of numberic values.
Thanks for your help
 
I guess you didnt understand my post.
say that card$(1) = "Ace of Spades"
card$(2) = "Two of Spades"
card$(3) = "Three of Spades"...you get the point.
get a random number by using the random generator that you had and then place that number after the string:
card$(random number here) it will give you a random preset string.

If you want a random string of letters then you can use the ASCII scan code.
 
Oh right. Thank you so much and please excuse my ignorance. thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top