Making an Answer

  • Thread starter Thread starter Robert Couchman
  • Start date Start date
R

Robert Couchman

Hello All,

i have a userform, textbox1 is where the user types in
there question (has to be a yes no answer!)

how do i generate a random response when they press
commandbutton1?

it can either be:
yes, no, or maybe

any help on this?

thank you,

Robert Couchman
 
Randomize 'init the generator.

i = Int((3 * Rnd) + 1) ' integer between 1 and 3 rondomized
 
Dim r as Single
Dim ans as String
r = rnd()
if r <= 1/3 then
ans = "Yes"
elseif r <= 2/3 then
ans = "No"
else
ans = "Maybe"
End if
 
Dim aryAns

aryAns = Array("Yes", "No", "Maybe")

MsgBox aryAns(Int(Rnd() * 3))



--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top