deal or no deal game, if statement help

jason1987

Member
Joined
Apr 15, 2007
Messages
14
Programming Experience
Beginner
I am doing a deal or no deal game, i currently have managed to get the values listed at the bottom to appear randomly in 22 buttons each time form loaded.


I now need to make a picture box appear with the same tag as the box that is clicked.
for example I have a button with the tag 0.01 and now picturebox1 with the tag 0.01 also.
How will i code this as it will be a different button each time with the 0.01 tag
I have 22 different tagged buttons and 22 different tagged picture boxs which im using to cover up something on my background when the button with the same tag is clicked
the values:
0.01,0.10,0.50,1,5,10,50,100,250,500,750,1000,3000,5000,10000,15000,20000,35000,50000,75000,100000,250000


i think i need a rather long if statement to do this, saying if when button x is clicked and it has tag y then picturebox1.show??
any help given, many thanks
 
Here's an idea, add all buttons to its own Panel and all pictureboxes to its own Panel. With this code you first AddAllButtonHandlers to add same Click handler for all buttons. The Buttons_Click handler method gets the Tag from the button that was clicked and checks all pictureboxes to find the corresponding:
VB.NET:
Sub AddAllButtonHandlers()
    For Each btn As Button In ButtonsPanel.controls
        AddHandler btn.Click, AddressOf Buttons_Click
    Next
End Sub

Private Sub Buttons_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
    Dim btn As Button = sender
    For Each pb As PictureBox In PictureboxesPanel.controls
        If pb.Tag = btn.Tag Then
            pb.Show()
            Exit For
        End If
    Next
End Sub
If you have Named the pictureboxes in a way that is easy to find from the button clicked you can instead of iterating all pictureboxes to search use the Controls.Find method.
 
Sorry I may not have read what you said properly (eyes are hurting), but could you not just put them in a multidimensional array?

And then find the index of the button in the first column and show the picturebox of the same index in the next column? Or Two Lists maybe

EDIT:

JH's method = probably better

Mine = similar

VB.NET:
    Dim btnList As New List(Of Button)
    Dim picList As New List(Of PictureBox)

    Private Sub AddObjects()

        For i As Integer = 0 To 10

            Dim btn As New Button
            AddHandler btn.Click, AddressOf ButtonsClick
            Me.Controls.Add(btn)

            btnList.Add(btn)

            Dim picBox As New PictureBox
            Me.Controls.Add(picBox)

            picList.Add(picBox)

        Next

    End Sub

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

        Dim btn As Button = sender

        picList(btnList.IndexOf(btn)).Show()

    End Sub
 
Last edited:
Another idea much simpler (but not same as your specification) is to only use pictureboxes and display the "hidden" image initially, when a picturebox is clicked you reveal the content by changing its image.
 
lol, i haven't got a clue how i would even go about that???

The code i currently have to randomise the button tags, work out the average of the button tags left is below:
VB.NET:
[SIZE=2]
[/SIZE][SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] Form1_Load([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] eventSender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] eventArgs [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]MyBase[/COLOR][/SIZE][SIZE=2].Load
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] I [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Integer
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] RandNumber [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Integer
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] Value() [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]String
[/COLOR][/SIZE][SIZE=2]
Value = Split([/SIZE][SIZE=2][COLOR=#a31515]"0.01,0.10,0.50,1,5,10,50,100,250,500,750,1000,3000,5000,10000,15000,20000,35000,50000,75000,100000,250000"[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#a31515]","[/COLOR][/SIZE][SIZE=2], , CompareMethod.Binary)

Randomize()
RandNumber = [/SIZE][SIZE=2][COLOR=#0000ff]CShort[/COLOR][/SIZE][SIZE=2](Rnd(1) * 21)

[/SIZE][SIZE=2][COLOR=#0000ff]For[/COLOR][/SIZE][SIZE=2] I = 0 [/SIZE][SIZE=2][COLOR=#0000ff]To[/COLOR][/SIZE][SIZE=2] btn.Count - 1
[/SIZE][SIZE=2][COLOR=#0000ff]Do[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Until[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Not[/COLOR][/SIZE][SIZE=2] CheckCaption(Value(RandNumber))
RandNumber = [/SIZE][SIZE=2][COLOR=#0000ff]CShort[/COLOR][/SIZE][SIZE=2](Rnd(1) * 21)
[/SIZE][SIZE=2][COLOR=#0000ff]Loop[/COLOR][/SIZE][SIZE=2] 
btn(I).Tag = Value(RandNumber)
[/SIZE][SIZE=2][COLOR=#0000ff]Next[/COLOR][/SIZE][SIZE=2] 

[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Sub
[/COLOR][/SIZE][SIZE=2]
[/SIZE][SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Function[/COLOR][/SIZE][SIZE=2] CheckCaption([/SIZE][SIZE=2][COLOR=#0000ff]ByRef[/COLOR][/SIZE][SIZE=2] sNumber [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2]) [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Boolean
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] J [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Integer
[/COLOR][/SIZE][SIZE=2]
CheckCaption = [/SIZE][SIZE=2][COLOR=#0000ff]False
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#008000]'Check if number wasnt given before...
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]For[/COLOR][/SIZE][SIZE=2] J = 0 [/SIZE][SIZE=2][COLOR=#0000ff]To[/COLOR][/SIZE][SIZE=2] btn.Count - 1
[/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] btn(J).Tag = sNumber [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE][SIZE=2] CheckCaption = [/SIZE][SIZE=2][COLOR=#0000ff]True
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Next[/COLOR][/SIZE][SIZE=2] 

[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Function
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] btn_Click([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Object[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] btn.Click
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] ClickedBtn [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Button = [/SIZE][SIZE=2][COLOR=#0000ff]CType[/COLOR][/SIZE][SIZE=2](sender, Button)
[/SIZE][SIZE=2][COLOR=#0000ff]With[/COLOR][/SIZE][SIZE=2] ClickedBtn
.Visible = [/SIZE][SIZE=2][COLOR=#0000ff]False
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]With
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Sub
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] BtnCalc_Click([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] BtnCalc.Click
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] J [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Integer
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] Total [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Double
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] VisibleCount [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Integer
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]For[/COLOR][/SIZE][SIZE=2] J = 0 [/SIZE][SIZE=2][COLOR=#0000ff]To[/COLOR][/SIZE][SIZE=2] btn.Count - 1
[/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] btn(J).Visible = [/SIZE][SIZE=2][COLOR=#0000ff]True[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=2]Total = Total + [/SIZE][SIZE=2][COLOR=#0000ff]CDbl[/COLOR][/SIZE][SIZE=2](btn(J).Tag)
VisibleCount = VisibleCount + 1
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]If
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Next
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].lblArv.Text = (Total / VisibleCount).ToString([/SIZE][SIZE=2][COLOR=#a31515]"c0"[/COLOR][/SIZE][SIZE=2])
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Sub
[/COLOR][/SIZE]

and my attempt so far to do this picturebox thingy im trying is this, but thats not working yet:
VB.NET:
[SIZE=2]
[/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] AddAllButtonHandlers()
[/SIZE][SIZE=2][COLOR=#0000ff]For[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Each[/COLOR][/SIZE][SIZE=2] btn [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Button [/SIZE][SIZE=2][COLOR=#0000ff]In[/COLOR][/SIZE][SIZE=2] ButtonPanel1.Controls
[/SIZE][SIZE=2][COLOR=#0000ff]AddHandler[/COLOR][/SIZE][SIZE=2] btn.Click, [/SIZE][SIZE=2][COLOR=#0000ff]AddressOf[/COLOR][/SIZE][SIZE=2] Buttons_Click
[/SIZE][SIZE=2][COLOR=#0000ff]Next
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Sub
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] Buttons_Click([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs)
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] btn [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Button = sender
[/SIZE][SIZE=2][COLOR=#0000ff]For[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Each[/COLOR][/SIZE][SIZE=2] pb [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] PictureBox [/SIZE][SIZE=2][COLOR=#0000ff]In[/COLOR][/SIZE][SIZE=2] PictureBoxPanel1.Controls
[/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] pb.Tag = btn.Tag [/SIZE][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=2]pb.Show()
[/SIZE][SIZE=2][COLOR=#0000ff]Exit[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]For
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]If
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]For[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Each[/COLOR][/SIZE][SIZE=2] pb1 [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] PictureBox [/SIZE][SIZE=2][COLOR=#0000ff]In[/COLOR][/SIZE][SIZE=2] PictureBoxPanel2.Controls
[/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] pb1.Tag = btn.Tag [/SIZE][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=2]pb1.Show()
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]If
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Exit[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]For
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Next
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Next
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Sub
[/COLOR][/SIZE]
 
To randomize you just have to swap some random elements of the array, then distribute them over the controls. There is a random swapping example here: http://www.vbdotnetforums.com/showthread.php?t=12700
You should anyway use the Random class and not the legacy rnd and randomize methods.
 
What I think JH is trying to say is:

Have a blank picturebox.
Have a imagelist of all the images

Have the button.tag property the index of the image you wish to show.

Then its simply set the picturebox.image property equal to the index of the image.

So on button click:

VB.NET:
PictureBox.Image = ImageList.Images(buttonClicked.Tag)
 
i dont understand how i can use that example for what i require, sorry you can probably tell im a bit of a newbie at this. lol
 
I am not sure how Deal or no Deal works. But could you not also set the location of the picturebox where you need it.

To be honest I should read your specification again.
 
i have 22 pictureboxes and 22 correspodning buttons (tag wise) however the buttons are randomized.
i just need to make the pictureboxes in pictureboxpanel1 and pictureboxpanel2 appear (covering part of the background) when the button with the same tag is clicked in buttonpanel1.

this is the code i have currently
VB.NET:
[LEFT]Sub AddAllButtonHandlers()
        For Each btn As Button In ButtonPanel1.Controls
            AddHandler btn.Click, AddressOf Buttons_Click
        Next
    End Sub

    Private Sub Buttons_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim btn As Button = sender
        For Each pb As PictureBox In PictureBoxPanel1.Controls
            If pb.Tag = btn.Tag Then
                pb.Show()
                Exit For
            End If
            For Each pb1 As PictureBox In PictureBoxPanel2.Controls
                If pb1.Tag = btn.Tag Then
                    pb1.Show()
                End If
                Exit For
            Next
        Next
    End Sub[/LEFT]
 
Here, take a look at this. It's messy and only with 4 buttons but it shows the principle, I hope.

Thinking about it, you are going to want to create a new picturebox everytime you click.
 

Attachments

  • Deal Or No Deal.zip
    16.9 KB · Views: 28
Last edited by a moderator:
I dont think i need to do that, i believe i could just make them visible
I have 2 pictureboxpanels because there is two coloumns of pictureboxs on either side of my form.

I have attached my game so far, might help me explain it if you see it yourself, all the code is on form1.
still dont appear to be doing as i require. Behind the pictureboxes on my form is the values as a background picture which is what im covering, i have had to remove this so i can post it on here.

there has to be some way to do this, lol been stuck on this for a while now
 

Attachments

  • project1.zip
    45.2 KB · Views: 29
Last edited by a moderator:
Well I can tell you that its because the AddHandler isn't working, I can't tell you why as I don't know as you seem to be mixing components of VB6 and VB.NET so I haven't a clue...sorry.

You don't seem to have even called the AddHandlers Sub Routine?

Change the whole code to this:

VB.NET:
Option Strict Off
Option Explicit On
Friend Class Form1
	Inherits System.Windows.Forms.Form
	
	
	Private Sub Form1_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
        Dim I As Integer
		Dim RandNumber As Integer
		Dim Value() As String
		
        Value = Split("0.01,0.10,0.50,1,5,10,50,100,250,500,750,1000,3000,5000,10000,15000,20000,35000,50000,75000,100000,250000", ",", , CompareMethod.Binary)
		
		Randomize()
        RandNumber = CShort(Rnd(1) * 21)
		
		For I = 0 To btn.Count - 1
			Do Until Not CheckCaption(Value(RandNumber))
                RandNumber = CShort(Rnd(1) * 21)
			Loop 
            btn(I).Tag = Value(RandNumber)
		Next 
		
	End Sub
	
	Private Function CheckCaption(ByRef sNumber As String) As Boolean
        Dim J As Integer
		
		CheckCaption = False
		'Check if number wasnt given before...
		For J = 0 To btn.Count - 1
            If btn(J).Tag = sNumber Then CheckCaption = True
		Next 
		
	End Function

    Private Sub BtnCalc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnCalc.Click

        Dim J As Integer
        Dim Total As Double
        Dim VisibleCount As Integer

        For J = 0 To btn.Count - 1
            If btn(J).Visible = True Then
                Total = Total + CDbl(btn(J).Tag)
                VisibleCount = VisibleCount + 1
            End If
        Next

        Me.lblArv.Text = (Total / VisibleCount).ToString("c0")

    End Sub

    Private Sub Buttons_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn.Click
        Dim btn As Button = sender
        For Each pb As PictureBox In PictureBoxPanel1.Controls
            If pb.Tag = btn.Tag Then
                pb.Visible = True
                Exit For
            End If
            For Each pb1 As PictureBox In PictureBoxPanel2.Controls
                If pb1.Tag = btn.Tag Then
                    pb1.Visible = True
                End If
                Exit For
            Next
        Next
        btn.Visible = False
    End Sub

End Class
 
Lol no worries.

It's best not to mix VB6 and VB.NEt because it usually does result in a mess.

I have constructed the project, in the way you wanted in pure VB.NET. I have also annotated all the code so you can see whats going on. It may be of use.
 

Attachments

  • Deal Or No Deal.zip
    32.6 KB · Views: 38
Back
Top