Alex122486
September 16th, 2001, 10:36 AM
i am a beginner that is trying to get mutilple bubles to float upwards in a form (using the circle command to test myself,i already know how with using premade shapes)i can get 1 buble to go up at a time but i want at least 9. (i would also like different colors for each buble) (this is also in vb4 but i do have a working model of 6) heres the code:
Public Function bub()
Dim rndnumx As Long 'defines variables
Dim rndnumy As Long '
Top: 'endless loop untill told to stop
r = 255 * Rnd 'random color for circles
g = 255 * Rnd '
b = 255 * Rnd '
rndnumx = Form1.Width 'defines the value for
rndnumy = Form1.Height 'which the circle will
'work with
nus = Rnd 'random position for the start of the
'circle
Do Until rndnumy = 0 'ends when the cirle has
'reached the top of the form
'creates a circle with a
'random color
Circle (rndnumx * nus, rndnumy), 300, RGB(r, g, b)
For num = 1 To 8000 'delay the circle
Next num
'clears the previous circle using the forms
'back color
Circle (rndnumx * nus, rndnumy), 300, vbBlack
'changes the position of the cirlce to make it
'go "up"
rndnumy = rndnumy - 5
'so the user can end the loop
DoEvents
'when the user chooses another demo or stops
'the demo with the mnustop tab mnububles.checked
'equals false
If mnububles.Checked = False Then
GoTo bot
End If
Loop
'does the loop over again
GoTo Top
bot:
End Function
Public Function bub()
Dim rndnumx As Long 'defines variables
Dim rndnumy As Long '
Top: 'endless loop untill told to stop
r = 255 * Rnd 'random color for circles
g = 255 * Rnd '
b = 255 * Rnd '
rndnumx = Form1.Width 'defines the value for
rndnumy = Form1.Height 'which the circle will
'work with
nus = Rnd 'random position for the start of the
'circle
Do Until rndnumy = 0 'ends when the cirle has
'reached the top of the form
'creates a circle with a
'random color
Circle (rndnumx * nus, rndnumy), 300, RGB(r, g, b)
For num = 1 To 8000 'delay the circle
Next num
'clears the previous circle using the forms
'back color
Circle (rndnumx * nus, rndnumy), 300, vbBlack
'changes the position of the cirlce to make it
'go "up"
rndnumy = rndnumy - 5
'so the user can end the loop
DoEvents
'when the user chooses another demo or stops
'the demo with the mnustop tab mnububles.checked
'equals false
If mnububles.Checked = False Then
GoTo bot
End If
Loop
'does the loop over again
GoTo Top
bot:
End Function