您可以使用布尔值来跟踪上次选择的文本框
当您单击价格文本框时,将布尔值设置为真。当您单击 Cash Tendered 文本框时,将布尔值设置为 false。当您单击键盘中的一个数字按钮时,测试布尔值以查看最后选择的文本框,然后将数字输入该文本框。
例子:
Public Class Form1
Dim lastClickedTextBox1 As Boolean
Private Sub TextBox1_Click(sender As Object, e As EventArgs) Handles TextBox1.Click
lastClickedTextBox1 = True
End Sub
Private Sub TextBox2_Click(sender As Object, e As EventArgs) Handles TextBox2.Click
lastClickedTextBox1 = False
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If lastClickedTextBox1 = True Then
TextBox1.Text = "Box 1 was it"
Else
TextBox2.Text = "Box 2 was it"
End If
End Sub
End Class