G_Waddell
Practically a Master Poster
623 posts since Nov 2009
Reputation Points: 107
Solved Threads: 95
Skill Endorsements: 6
Try this:
Public Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
Dim KeyChr As Char = e.KeyChar
If KeyChr.ToString.ToUpper = "A" Then
Label1.Text += KeyChr.ToString
End If
End Sub
Anytime an a or an A is entered in the textbox it gets echoed to the label.
If you don't want it echoed, and want it removed from the textbox, inside the if block, just add this e.Handled = True
tinstaafl
Nearly a Posting Virtuoso
1,470 posts since Jun 2010
Reputation Points: 421
Solved Threads: 262
Skill Endorsements: 14
I assume when you say column you mean the index of a letter in a string. To remove a letter from a string you can use the Remove method. You probable want to use a button to do this:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Indx As Integer = 0
Dim NewString As String = TextBox1.Text
Indx = NewString.ToUpper.IndexOf("A")
If Not (Indx = 0) Then
Label1.Text += NewString.Substring(Indx, 1)
TextBox1.Text = NewString.Remove(Indx, 1)
End If
End Sub
Instead of using a literal string("A") you can use any character or string variable, also instead of using the index of a particular letter you can just use any number that corresponds to a particular position in the string regardless of letter.
You can include functionality to use the Enter key like this:
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If e.KeyChar = ChrW(Keys.Return) Then
Button1.PerformClick()
e.Handled = True
End If
End Sub
tinstaafl
Nearly a Posting Virtuoso
1,470 posts since Jun 2010
Reputation Points: 421
Solved Threads: 262
Skill Endorsements: 14