2
Contributors
6
Replies
11
Views
6 Years
Discussion Span
Last Post by VB_CMI
0

See if this helps.

'// Give focus to TextBox and Send the BackSpace key.
        TextBox1.Focus() : SendKeys.Send("{BACKSPACE}")

Or you can use this, which only removes the last char. unlike the SendKeys code.

With TextBox1
            If Not .Text = "" Then .Text = .Text.Substring(0, .TextLength - 1)
        End With

Edited by codeorder: n/a

0

See if this helps about recognizing which TextBox is selected.

Public Class Form1
    Private mySelectedCoolTextBox As TextBox '// used to determine which TextBox has Focus.

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        mySelectedCoolTextBox.Focus() : SendKeys.Send("{BACKSPACE}") '// send the BackSpace key to your selected TextBox.
    End Sub

    Private Sub TextBox1_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) _
                                    Handles TextBox1.GotFocus, TextBox2.GotFocus
        mySelectedCoolTextBox = CType(sender, TextBox) '// set your selected TextBox.
    End Sub
End Class
0

Thanks Codeorder. between i solve using aother coding you want to find out how i do it?

0
If textbox_GotFocus = 1 Then
            With textbox
                If Not .Text = "" Then
                    .Text = .Text.Substring(0, .TextLength - 1)
                End If
            End With
        ElseIf textbox_GotFocus = 2 Then
            With textbox2
                If Not .Text = "" Then
                    .Text = .Text.Substring(0, .TextLength - 1)
                End If
            End With
        End If
This question has already been answered. Start a new discussion instead.
Be sure to adhere to our posting rules.