Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: [VB.Net] Create panels when in While() loop  (Read 4278 times)

0 Members and 1 Guest are viewing this topic.

liambiscuit

    Topic Starter


    Hopeful

    [VB.Net] Create panels when in While() loop
    « on: June 22, 2009, 03:13:54 PM »
    Code: [Select]
    Public Class Form1

        Private Function RandomNumber(ByVal min As Integer, ByVal max As Integer) As Integer
            Dim random As New Random()
            Return random.Next(min, max)
        End Function 'RandomNumber

        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Dim planetcount = RandomNumber(1, 10)
            While (planetcount > 0)
                planetcount -= 1

                'Code here =D

            End While
        End Sub
    End Class

    I figured since there wasn't much code yet, might as well put it all.

    where it says " Code here =D " I want to put the panel, but if i do this
    Code: [Select]
    ...
    dim panel as panel
    ...

    the next time the program loops it will create a panel with the SAME NAME giving a code conflict.

    I want the code to be modifiable in the future so i can have many more, so i cannot do it manually "planet1, planet2, Etc"

    So how would i make a loop that would name the panels with ("Planet"+ planetcount)= Planet1, Planet2, etc.? or something like that so that the names become unique, no matter how many loops the program goes through.

    Thanks for reading,
    Liam
    " When the rich wage war its the Poor who die "
            Linkin Park



    Whoever said that nothing is impossible has obviously never tried to slam a revolving door. -- Lauren

    You cannot buy your friends but you can buy them pizza - AzureBlade49

    Bones92



      Hopeful

    • Website Designer and Microcontroller Programmer
    • Thanked: 3
      • PIC Programming New Zealand
    • Computer: Specs
    • Experience: Experienced
    • OS: Windows 7
    Re: [VB.Net] Create panels when in While() loop
    « Reply #1 on: June 25, 2009, 10:41:40 PM »
    try
    Code: [Select]
    dim panel as new panel
    with panel
    .location...
    .name...
    end with

    Something like that should work, although I normally just use arrays. What are you trying to do?


    liambiscuit

      Topic Starter


      Hopeful

      Re: [VB.Net] Create panels when in While() loop
      « Reply #2 on: July 12, 2009, 10:22:36 PM »
      I was trying to make 10 unique panels each with uniquely modifiable statistics. How i set it up in the main post, whenever I tried to change an attribute, it would apply to -ALL- the panels.
      " When the rich wage war its the Poor who die "
              Linkin Park



      Whoever said that nothing is impossible has obviously never tried to slam a revolving door. -- Lauren

      You cannot buy your friends but you can buy them pizza - AzureBlade49