Hello, I am making a program, when I click picturebox, some text appears on the form. So I got that part right, I am clicking picturebox and text is appearing, but the problem is, that I dont know how to clear that text one by one after certain amount of time. I would like to have control of each drawn text(e.g. change opacity, color) and remove it from form after some time. Is it possible to do that stuff in VB, or I should try something else, what would you guys recommend me to do?

Add a label to the form at design time and on form load do

Label1.Parent = PictureBox1
Label1.BackColor = Color.Transparent

When you assign text to the label it will be visible. To make it disappear just assign the null string to the label. If the label text is the same colour as the picture you may have to temporarily set the BackColor to something other than Transparent.

Added your code to form load and added

label1.text = "11"

to a button event, but it doesn't show and do anything, I even experimented with backcolor. Am I doing something wrong? btw first time using this "parent" command.

Public Class Form1

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

        Label1.Text = ""
        Label1.Parent = PictureBox1
        Label1.BackColor = Color.Transparent

    End Sub

    Private Sub btnShow_Click(sender As System.Object, e As System.EventArgs) Handles btnShow.Click

        Label1.Text = "Some text"

    End Sub

    Private Sub btnHide_Click(sender As System.Object, e As System.EventArgs) Handles btnHide.Click

        Label1.Text = ""

    End Sub

End Class

Works for me. You don't even have to make the background colour transparent.

can you explain exactly what "parent" function does?

When you drop a label onto the form at design time it is added to the Controls collection of the main form (Me). This is the same as if you created it at run time and did

Me.Controls.Add(newlabel)

What you want to do is to add the label to the Controls collection of the PictureBox. Simply stated, you are making PictureBox1 the Parent (or container) control for the label.

Alright, thank you

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.