0

How do i make a label display if the textbox value that was entered is invalid?
This is my code so far and when i press the button to find the invaild source the label is suppose to appear but nothing is happening when i click the button.

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

        Enflbl.Hide()

End Sub



    Private Sub cmdFind_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdFind.Click
        'Finds the employee associated with the employee ID entered by the user
        FindAcct()

        If txtUpdateID.Text = False Then
            Enflbl.Show()
        End If
    End Sub
3
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by Reverend Jim
0

If Enflbl is a label in your form then you should use Enflbl.visible = true to show it and Enflbl.visible = false to hide it.

0
If txtUpdateID.Text = False Then

Will never work because you are comparing a string to a boolean. The short form of showing/hiding a label depending on a comparison is

Enflbl.Visible = txtUpdateID.Text = "some string value"

If txtUpdateID.Text is equal to the string value then the label is shown, otherwise it is hidden.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.