none
How to have the label clear by code?

    Question

  • I am currently working on a program, which has a label. I was hoping someone could help me out on how to have the "label" clear when the user hits the clear button.

    When the user clicks clear button, it is supposed to clear all textboxes, including the label.

    Any ideas? Here is what I'm talking about. Now I discovered that using "TotalPayLabel.Text.Clear() does not work. As you can see the question right in the code ' how do I clear label?

        Private Sub ClearToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClearToolStripMenuItem.Click  
            ' Clear all fields and start over.  
            NameTextBox.Clear()  
            WeeklySalesTextBox.Clear()  
            CommissionsTextBox.Clear()  
            TotalPayLabel.Text.Clear()              ' how do I clear Label?  
     
            ' Set NameTextBox back to focus after clear.  
            With NameTextBox  
                .Focus()  
            End With  
        End Sub 

    Thanks for any input you could give me. Much appreciated!
    Sunday, October 19, 2008 2:38 PM

Answers

  • TotalPayLabel.text = ""

    Should be enough

    Change "" to a text if you want it. (with the quotations)
    • Edited by Prits22 Sunday, October 19, 2008 2:42 PM
    • Marked as answer by CJ1985 Sunday, October 19, 2008 3:02 PM
    Sunday, October 19, 2008 2:41 PM

All replies

  • TotalPayLabel.text = ""

    Should be enough

    Change "" to a text if you want it. (with the quotations)
    • Edited by Prits22 Sunday, October 19, 2008 2:42 PM
    • Marked as answer by CJ1985 Sunday, October 19, 2008 3:02 PM
    Sunday, October 19, 2008 2:41 PM
  • Thank you pritesh22, that was exactly what I needed! I appreciate your help!

    Thank you again!
    Sunday, October 19, 2008 3:03 PM