I am new in vb.net please help.

Public Class Form1

    Private Sub RichTextBox1_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles RichTextBox1.KeyPress
        
        RichTextBox1.Text = " Not available "
        RichTextBox1.Select(RichTextBox1.Text.Length, 0)

    End Sub
End Class

I want this code to pass not available like" Not available Not available Not available "
Every time the user enter any key " Not available " adds to the string in text box.

Recommended Answers

Public Class Form1

    Private Sub RichTextBox1_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles RichTextBox1.KeyPress
        
        RichTextBox1.Text = RichTextBox1.Text & " Not available "
        RichTextBox1.Select(RichTextBox1.Text.Length, 0)

    End Sub
End Class
Jump to Post

All 3 Replies

Public Class Form1

    Private Sub RichTextBox1_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles RichTextBox1.KeyPress
        
        RichTextBox1.Text = RichTextBox1.Text & " Not available "
        RichTextBox1.Select(RichTextBox1.Text.Length, 0)

    End Sub
End Class

Thanks Pgmer
this is too easy now i am feeling stupid

:) Happy coding...

Be a part of the DaniWeb community

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