i'm using 4 pictureboxes and 1 textbox in one particular application. when i click on picturebox1 i need a certain value to be fed as input to the textbox, simillarly for the other pictureboxes too. how can it be done ?

Recommended Answers

All 3 Replies

Hello,

Let me see if i got this right, you want to use the pictureboxes as textboxes, and then pass the value from one of the pictureboxes to the textbox?

When the picturebox is loaded with a picture you could put a string into the Tag property. When you click on the picturebox you can copy the Tag value to the TextBox.

This will do the trick.

Private Sub PictureBox_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseClick, PictureBox2.MouseClick, PictureBox3.MouseClick, PictureBox4.MouseClick
        Dim strName As String = ""
        Dim text As PictureBox = sender
        strName = text.Name
        If strName = "PictureBox1" Then
            TextBox1.Text = "10" 'value you want
        End If
        If strName = "PictureBox2" Then
            TextBox1.Text = "20" 'value you want
        End If
        If strName = "PictureBox3" Then
            TextBox1.Text = "30" 'value you want
        End If
        If strName = "PictureBox4" Then
            TextBox1.Text = "40" 'value you want
        End If
    End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.