Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / some one who knows

Author
Message
Terabyte
23
Years of Service
User Offline
Joined: 28th Dec 2002
Location: UK
Posted: 5th May 2003 18:11
VB6 (sorry its off the topic but i didnt know where else to go and anyway your all nice people [img] [/img]
i want text2 to produce a random bit of text. the text it shows is written in text1(0) to text1(35). the randomiser only produces a 0 or 1 output it doesnt produce up to 35 like its meant to

Private Sub Command2_Click()
Text2.Text = Text1(Rnd(35)).Text
End Sub

[img][/img]
Info Q.&statments corect@da time of going to pres. I acept 0 responsibility for typos gramaticaly incorect txt swering or pety complant tht u hve so just piss off unles u r anserin da Q.
Hubdule
23
Years of Service
User Offline
Joined: 3rd Sep 2002
Location: Gundelsheim
Posted: 5th May 2003 18:51 Edited at: 6th May 2003 13:26
Private Sub Command2_Click()
Text2.Text = Text1(Int(Rnd*35)).Text
End Sub


Hope that's what you wanted



Terabyte
23
Years of Service
User Offline
Joined: 28th Dec 2002
Location: UK
Posted: 5th May 2003 20:10
yes its exaclty it

erm

so how does that work then
how come you needed rnd*35
and whats the fromtext< and fromtext> for?

anyway
thanks
it works [img]:[/img]

Info Q.&statments corect@da time of going to pres. I acept 0 responsibility for typos gramaticaly incorect txt swering or pety complant tht u hve so just piss off unles u r anserin da Q.
Kangaroo2
23
Years of Service
User Offline
Joined: 26th Sep 2002
Location: United Kingdom
Posted: 5th May 2003 21:05
"If FromText<0 Then FromText=0
If FromText>35 Then FromText=35"

Surely you don't need these two lines? The line "FromText=Int(Rnd*35)" should obviously pick an integer between 0 and 35 anyways?

Coming Soon! Kangaroo2 Studio... wait and quiver with anticipation! lol
[email protected] - http://www.kangaroo2.com - If the apocalypse comes, email me
Terabyte
23
Years of Service
User Offline
Joined: 28th Dec 2002
Location: UK
Posted: 6th May 2003 10:31 Edited at: 6th May 2003 10:32
oh yeah. [img] [/img] you dont [img] [/img]

ust out of interest why do you have to write Rnd*35 why not just rnd(35) like on dbpro. the dbpro way seems a lot more logical [img][/img]

Info Q.&statments corect@da time of going to pres. I acept 0 responsibility for typos gramaticaly incorect txt swering or pety complant tht u hve so just piss off unles u r anserin da Q.
Rob K
Retired Moderator
23
Years of Service
User Offline
Joined: 10th Sep 2002
Location: Surrey, United Kingdom
Posted: 6th May 2003 10:34
Rnd produces a random value between 0 and 1, the *35 part multiplies that value up to give a random value between 0 and 35. Personally I also prefer DBP's approach.

Current Project: TANK MELÉE [Artwork]

Do you want Windows menus in your DBP apps? - Get my plugin: http://snow.prohosting.com/~clone99/downloads/tpc_menus_101.zip
MiniMark
23
Years of Service
User Offline
Joined: 21st Mar 2003
Location: Australia
Posted: 8th May 2003 07:21
In simple maths if you have something in brackets you multiply it...exactly the same thing just written different

--Twin P4 Xeon 2.0 Ghz, GeForce Quadro4 XGL 128MB, 1Gb DDR RAM, 19" Flat Screen--
The Wendigo
23
Years of Service
User Offline
Joined: 13th Sep 2002
Location: A hole near the base of a tree in the US
Posted: 8th May 2003 08:46
VB6 makes sence to me. DB does too!

Current Projects: mini BSP maker 50%, Height Mapper with many features 75%, FPS/RTT Nameless at the moment 15%
Zed
23
Years of Service
User Offline
Joined: 20th Sep 2002
Location:
Posted: 8th May 2003 22:00
One thing to bare in mind though.

rnd generates a number between 0 and 1 but not including 1 so
int(0.9999999999*35) will be 34.

Login to post a reply

Server time is: 2026-07-11 02:13:37
Your offset time is: 2026-07-11 02:13:37