English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I'm trying to do an eventHandler for my yahtzee program. When the user clicks a dice I want a label under it to display "hold." This is the procedure I wrote:

Sub dice_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles pic1.Click, pic2.Click, pic3.Click, pic4.Click, pic5.Click
If pic1.Click Then
Me.Label1.Text = "Hold"
End If
End Sub

A blue line shows up under pic1.click and says I need a raise event procedure or something. What am I doing wrong?

2007-06-03 10:35:17 · 2 answers · asked by ella 2 in Computers & Internet Programming & Design

2 answers

Use the sender object to determine what picture was clicked.
You can create a myPic variable and assignn the sender object to it. Once assigned (myPic = sender) you can read the name or tag property into a string variable and use a select case .

Dim myPic as PictureBox

myPic = sender
strTag = myPic.Tag
strName = myPic.name

select case strTag
case "Die1"
labelPic1.text ="'HOLD"
case "Die2"
ect....

If you use the tag property you will have to load the tags via the properties at design time or load them in run time.

2007-06-03 17:44:07 · answer #1 · answered by MarkG 7 · 0 0

you have to use the sender object to see what was clicked


If sender Is Me.pic1 Then
Me.Label1.Text = "Hold"
End If

2007-06-03 18:41:15 · answer #2 · answered by shnhwk 2 · 1 0

fedest.com, questions and answers