|
-
Aug 24th, 2009, 10:20 PM
#1
Thread Starter
PowerPoster
[RESOLVED] Control Arrays, Anyone?
I need to know how to make a control array in the Form_Load() sub routine. I am trying to make a platform game that is totally random in fact, that nothing is similar in each execution of the program.
So far I have this as my source code:
Code:
Dim i as Integer
Public Sub Form_Load()
For i = 0 to 99
End Sub
I have a huge free products range, of computer software in which you can download using any kind of 64-Bit Web Browser. Also there is coming a Social Networking section that I am making on my Website...
|Ambra Productions Inc. | The Black Sun Society | The Black Shield | Ambra College | Church of the Black Sun | Ambra Productions Inc's Homepage | Boomtick Venues: Ambar Nightclub, Jack Rabbit Slim's, Villa Nightclub and Lucy's Love Shack | Pasta Ambra | Fish Feast Company | Wallet Wizard | Ambrose Liquor | Ambar Tavern | Ambra University | Ambra Cheese |
Do you wish to do unpaid work for me??? If so, the PM me on this Forum, and then we can get to work, programming for the future of computers go by the name of ThEiMp. This is my ghost writers name. Also my nickname, means that I am: The Imperial of the Technology Industry, so then to make it really short, I just then wrote: The Imp, which is where I get the nickname from...
-
Aug 24th, 2009, 10:24 PM
#2
Re: Control Arrays, Anyone?
Try looking at this FAQ, post #3. Also, searching the forums for control arrays will return so many examples.
-
Aug 24th, 2009, 10:26 PM
#3
Re: Control Arrays, Anyone?
The easiest way would be to just add a control (example, a PictureBox) to the form and set its Index property to 0. Then you could have something like:
vb Code:
Option Explicit
Private Sub Form_Load()
Dim i As Integer
For i = 1 To 99
Load Picture1(i)
Picture1(i).Move i * Picture1(i).Width, 100
Picture1(i).Visible = True
Next i
End Sub
Private Sub Form_Unload(Cancel As Integer)
Dim i As Integer
For i = 1 To Picture1.UBound
Unload Picture1(i)
Next i
End Sub
-
Aug 25th, 2009, 12:27 AM
#4
Thread Starter
PowerPoster
Re: Control Arrays, Anyone?
How can I get the PictureBox control array to only move a random control in the array, into another position without disrupting all the rest.
eg:
Picture1(1).Top = "100"
Picture1(2).Top = "0"
Picture1(3).Top = "100"
And so on.
Also I don't wish this to only be one of them. But a randomly determined number of them, in fact.
I have a huge free products range, of computer software in which you can download using any kind of 64-Bit Web Browser. Also there is coming a Social Networking section that I am making on my Website...
|Ambra Productions Inc. | The Black Sun Society | The Black Shield | Ambra College | Church of the Black Sun | Ambra Productions Inc's Homepage | Boomtick Venues: Ambar Nightclub, Jack Rabbit Slim's, Villa Nightclub and Lucy's Love Shack | Pasta Ambra | Fish Feast Company | Wallet Wizard | Ambrose Liquor | Ambar Tavern | Ambra University | Ambra Cheese |
Do you wish to do unpaid work for me??? If so, the PM me on this Forum, and then we can get to work, programming for the future of computers go by the name of ThEiMp. This is my ghost writers name. Also my nickname, means that I am: The Imperial of the Technology Industry, so then to make it really short, I just then wrote: The Imp, which is where I get the nickname from...
-
Aug 26th, 2009, 07:32 AM
#5
Re: Control Arrays, Anyone?
Generate a random number to determine which control to move. Here is some code that doesn't quite do that, but should show you enough to get you there (I think). Start a project and put a picture box on the form. Call it "pb," and give it an index of 0 as mentioned earlier.
After the form loads, double click it to re-gen.
Code:
Option Explicit
Private Sub Form_DblClick()
Call randGen
End Sub
Private Sub randGen()
Dim myRand As Integer
Dim randLeft As Integer
Dim randTop As Integer
Dim i As Integer
Randomize
myRand = Int((99 - 1 + 1) * Rnd + 1) 'generates random number between 1 and 99
For i = 1 To myRand
randLeft = Int((Me.ScaleWidth - pb(0).Width - 1 + 1) * Rnd + 1)
randTop = Int((Me.ScaleHeight - pb(0).Height - 1 + 1) * Rnd + 1)
On Error Resume Next
Load pb(i)
pb(i).Left = randLeft
pb(i).Top = randTop
pb(i).Visible = True
Next i
Me.Caption = myRand
End Sub
Private Sub Form_Load()
Call randGen
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
|