|
-
Aug 16th, 2000, 10:38 AM
#1
Thread Starter
Lively Member
I'm trying to create a game where the number of Image Objects in the Form varies according to what the user does and how long he plays the game.
So, does anyone know how to insert new image objects, preferably arrayed, using just code as supposed to dragging it into the form during design time?
-
Aug 16th, 2000, 10:49 AM
#2
Member
yeah, make a dynamic array of the image object using:
Dim MyImages() as Image
Then you can keep redimming the array when needed.
-
Aug 16th, 2000, 11:13 AM
#3
PowerPoster
Well, the easiest way is when you create one
at design time and set it's index to 0. You
can load instances of this object in runtime
afterverbs:
Code:
'Add a picture box to a new project and
'set it's "Index" property to 0. Also
'add this code, then run the project.
Private Sub Form_Load()
Dim A As Long
For A = 0 To 10
'Load new control if necessary
If A > 0 Then: Load Picture1(A)
With Picture1(A)
'Randomize position and size
.Move Me.ScaleWidth * Rnd, Me.ScaleHeight * Rnd, Me.ScaleWidth / 3 * Rnd, Me.ScaleHeight / 3 * Rnd
'Set random color
.BackColor = 16777215 * Rnd
'Finally show it
.Visible = True
End With
Next
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|