|
-
May 14th, 2004, 11:06 AM
#1
Thread Starter
Junior Member
linking a image to text?
Hello,
ive made a programe similar to a lotto program, i would like to have 20 images of number balls on my programe, if the number on the ball was 12 for example i want it so that when the user clicks the image of ball 12 this then puts a number 12 in a text box and so on for each number!
Any ideas would be helpful
Thanks
-
May 15th, 2004, 01:11 PM
#2
Fanatic Member
that's simple, you just simply identify what image is which by its name.
like if your image is ball 12, call it imgBall12 or something like that.
And then, just write an event for when you click the image.
Something like this
VB Code:
Private Sub imgBall12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles imgBall12.Click
TextBox1.Text = TextBox1.Text & "12"
End Sub
hope that helps
-
May 15th, 2004, 02:05 PM
#3
If you use buttons (with pictures on them) then you can set their tag properties to "1", "2", "3"... etc and use the following code...
VB Code:
Private Sub ButtonX_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click, Button2.Click, Button3.Click '......continues for all your buttons
'just shows the number in the titlebar for now :)
Me.Text = Me.ActiveControl.Tag
End Sub
You only have to maintain 1 sub in this case.
Might be a bit messy but the simplest code I could think of.
I don't live here any more.
-
May 17th, 2004, 05:25 AM
#4
Junior Member
-
May 17th, 2004, 05:28 AM
#5
Thread Starter
Junior Member
Originally posted by LITHIA
that's simple, you just simply identify what image is which by its name.
like if your image is ball 12, call it imgBall12 or something like that.
And then, just write an event for when you click the image.
Something like this
VB Code:
Private Sub imgBall12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles imgBall12.Click
TextBox1.Text = TextBox1.Text & "12"
End Sub
hope that helps
Hi i've tried that and it works fine, the only problem im having now is that i have 6 text boxes, and say i click image 12 this puts the number 12 into textbox1 which is great, but then if i click image 40 this put the number 40 into the textbox1 too, i would like it to over write the last number. Also how would i make it so that the next number goes into textbox2 and 3 and so on......?
Thanks For your Time
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
|