Results 1 to 5 of 5

Thread: linking a image to text?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2004
    Posts
    21

    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

  2. #2
    Fanatic Member LITHIA's Avatar
    Join Date
    Dec 2002
    Location
    UK, England
    Posts
    575
    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:
    1. Private Sub imgBall12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles imgBall12.Click
    2.         TextBox1.Text = TextBox1.Text & "12"
    3.     End Sub

    hope that helps

  3. #3
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682
    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:
    1. 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
    2. 'just shows the number in the titlebar for now :)
    3.         Me.Text = Me.ActiveControl.Tag
    4.     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.

  4. #4
    Junior Member
    Join Date
    May 2004
    Posts
    27
    Interesting!!!

  5. #5

    Thread Starter
    Junior Member
    Join Date
    May 2004
    Posts
    21
    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:
    1. Private Sub imgBall12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles imgBall12.Click
    2.         TextBox1.Text = TextBox1.Text & "12"
    3.     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
  •  



Click Here to Expand Forum to Full Width