Detect TextBox Contents.

WiiFan2012

Member
Joined
Jan 15, 2010
Messages
17
Programming Experience
Beginner
I'm trying to write a program that detects the contents inside a textbox, and if empty displays a warning, and does not input anything into a rich text box. However, if something is detected, it would not display the warning and input the textbox's text into the rtb.

I got everything else, just need help with the textbox detection code.

Thanks!
 
For that you can use either KeyUp or TextChanged event handler e.g.
PHP:
    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, _
                                     ByVal e As System.EventArgs) Handles TextBox1.TextChanged

        Dim MyText As TextBox = CType(sender, TextBox)
        If MyText.Text <> String.Empty Then
            RichTextBox1.Text = MyText.Text
        Else
            RichTextBox1.Text = String.Empty
            MessageBox.Show("Please enter ... blah blah")
        End If

    End Sub

However to be certain if the texbox is left empty you can't use this approach.
You can only check when the users delete the very last character in the textbox.
Maybe i can suggest a better solution if you explain better your problem?
 
Back
Top