De: Bob Dietz À: Objet: Re: Ramdom Tips in Statusbar Date : jeudi 26 août 1999 14:45 Hi Colin, Let me try again. if your computer has been OFF and you turn it ON and START Word and run Chris Rae's code I'll quote it again here. (I'm not trying to pick on you Chris.) Sub TipInStatusBar() dim PhraseList As Variant PhraseList = array( _ "Smoking causes cancer!", _ "Your house is at risk if you do not keep up payment.", _ "Have you thought about a holiday recently?") application.StatusBar = PhraseList(Int((ubound(PhraseList) - _ LBound(PhraseList) + 1) * Rnd + LBound(PhraseList))) end Sub You will see, "Have you thought about a holiday recently?" appear in the status bar. This is what will happen everytime. (The first time the code gets run after the computer has been shut down.) if the code is changed to read Sub TipInStatusBar() dim PhraseList As Variant Randomize PhraseList = array( _ "Smoking causes cancer!", _ "Your house is at risk if you do not keep up payment.", _ "Have you thought about a holiday recently?") application.StatusBar = PhraseList(Int((ubound(PhraseList) - _ LBound(PhraseList) + 1) * Rnd + LBound(PhraseList))) end Sub then it is inpossible to predict exactly which of the three you will see in the statusbar, though it is possible to determine the probability for any given item. Ideally, the probability for any of the three quotes showing up would be 1/3. The reality is that one will appear more often than either of the other two. I don't know what the true probabilities are, but if I did, they might look something like Probability Phrase 37.1355% "Smoking causes ... 36.8389% "Have you thought ... 26.0256% "Your house is ... However random computers may often appear to be, it is very, very difficult to MAKE them do anything that is truely random. Hope this helps, Bob Dietz steadmancr@my-deja.com wrote: > We thought it was quite fun also. > > As far as my VBa skills go... I think the code I wrote in the initial > message says it all. The only programming experience I've had to date > is with WordBasic, so most of this stuff is very new to me (waiting to > go a good VB course for beginners, if anyone can recommend one in the > UK). > > I've just read Bob Dietz reply to your message, and I have no idea what > he's trying to say (sorry Bob). > > Thankyou for posting the code, works fine! > > Colin Steadman, > > In article <#xCUR8t7#GA.254@cppssbbsa04>, > "Chris Rae" wrote: > > I like this idea! Almost tempted to implement it in my office. I'm > > not sure what level your VBA is at so I hope I'm not patronising / > > confusing here. > > > > I've sat down and thought about this for a bit and unfortunately I > > can't come up with a clean way of doing this. I can't use constant > > arrays, so that's out. The Choose function looks promising but you > > can't work out the bounds and Iif only takes two arguments. So... > > here's my best attempt. > > > > Sub TipInStatusBar() > > dim PhraseList As Variant > > > > PhraseList = array( _ > > "Smoking causes cancer!", _ > > "Your house is at risk if you do not keep up payment.", _ > > "Have you thought about a holiday recently?") > > > > application.StatusBar = PhraseList(Int((ubound(PhraseList) - _ > > LBound(PhraseList) + 1) * Rnd + LBound(PhraseList))) > > end Sub > > > > Hope that's some use - it'll work but I've no doubt someone here will > > improve it! > > > > Chris > > Sent via Deja.com http://www.deja.com/ > Share what you know. Learn what you don't.