Deal or no deal beginners help, random problem

aikiscotsman

New member
Joined
Apr 20, 2008
Messages
1
Programming Experience
Beginner
Hi folks sorry if this is the wrong area to post.
i know you have probably had deal or no deal questions a lot.
im a total beginner doing vb.net at college. being asked to design a version of the game show. So far ive managed(with the help from my tutor) to set up 22 panels and insert 22 labels that are invsible. ive been able to asign each panel/label a box no 1 to 22 and randomized them. now im feel like ive forgoten everything i had learnt. I need to set up an array(forgot what they are) to asign the money values to each box and keep them randomized so each value is picked only once. please help. Ive also managed to avoid using the gui n set up and chosen to script everything
here it is so far,
thank you

:CODE:
VB.NET:
Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.BackColor = System.Drawing.Color.FromArgb(CType(0, Byte), CType(192, Byte), CType(192, Byte))
        Me.ClientSize = New System.Drawing.Size(712, 334)
        Me.Name = "Form1"
        Me.Text = "Form1"

    End Sub

#End Region

    '*******************************************************
    '*                                                     *             
    '*             Written By                     *
    '*                15 April 2008                        *
    '*                                                     *
    '*                    Version 2                        *
    '*                                                     *
    '*******************************************************

    Const boxes = 22

    Dim CPanel(boxes) As Panel
    Dim Clabel(boxes) As Label
    Dim Amount(boxes) As Integer ' Stores the money value 



    Sub CreateLabels()

        Dim k As Integer
        Dim amount() As Double


        For k = 1 To boxes

            Clabel(k) = New Label
            Clabel(k).Size = New Size(80, 30)
            Clabel(k).Location = New Point(10, 10)
            Clabel(k).BackColor = Color.White
            Clabel(k).Font = New Font("Pristina", 16, FontStyle.Bold)
            Clabel(k).Text = "BOX"
            Clabel(k).Visible = False

            CPanel(k).Controls.Add(Clabel(k))

        Next

    End Sub


    Sub CreatePanels()

        Const Gap = 10

        Dim k As Integer


        For k = 1 To boxes

            CPanel(k) = New Panel
            CPanel(k).Size = New Size(100, 50)
            If k <= 11 Then
                CPanel(k).Location = New Point(100, Gap + (k - 1) * 60)
            Else
                CPanel(k).Location = New Point(300, Gap + (k - 12) * 60)
            End If

            CPanel(k).BackColor = Color.Red

            Controls.Add(CPanel(k))

            AddHandler CPanel(k).Click, AddressOf panel_click

        Next

    End Sub



    Sub panel_click(ByVal sender As Object, ByVal e As System.EventArgs)

        Dim K As Integer

        For K = 1 To boxes
            If sender Is CPanel(K) Then
                CPanel(K).BackColor = Color.Yellow
                Clabel(K).Visible = True
            End If
        Next
    End Sub


    Sub InitialiseAmount()
        Dim amount() As Double

        Amount(1) = 0.01
        Amount(2) = 0.1
        Amount(3) = 5.0
        Amount(4) = 10.0
        Amount(5) = 25.0
        Amount(6) = 50.0
        Amount(7) = 75.0
        Amount(8) = 100.0
        Amount(9) = 200.0
        Amount(10) = 300.0
        Amount(11) = 400.0
        Amount(12) = 500.0
        Amount(13) = 750.0
        Amount(14) = 1000.0
        Amount(15) = 5000.0
        Amount(16) = 10000.0
        Amount(17) = 25000.0
        Amount(18) = 50000.0
        Amount(19) = 75000.0
        Amount(20) = 100000.0
        Amount(21) = 150000.0
        Amount(22) = 250000.0

        Dim K As Integer

        For K = 1 To boxes
            Amount(K) = K
        Next
    End Sub

    Sub JumbleBoxes()

        Dim K As Integer
        Dim number As Integer


        For K = 1 To boxes

            number = Int(Rnd(1) * (boxes - 1) + 1)
            Amount(0) = Amount(number)
            Amount(number) = Amount(K)
            Amount(K) = Amount(0)

        Next

    End Sub

    '*******************************************************
    '*                                                     *             
    '*               End of global declarations            *
    '*                                                     *
    '*******************************************************


    Private Sub Form1_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Activated

        Randomize()

        Call InitialiseAmount()
        Call JumbleBoxes()
        Call CreatePanels()
        Call CreateLabels()

        Me.Height = 1000
        Me.Width = 600

    End Sub



    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class
:CODE:

:CODE:
:CODE:
 

Latest posts

Back
Top