Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Private Sub btn0_Click()
SendKeys "0"
End Sub
How would you determine what text box to insert the number into if it's not active?If you're not in the textbox and you press a number button I'd want the value to go into the textbox, not wherever the cursor is at the time.
Private myTextBox As Variant
Private Sub btn1_Click()
SendStringToTextBox ("1")
End Sub
Private Sub btn2_Click()
SendStringToTextBox ("2")
End Sub
' Same for buttons 3 through 0
Private Sub TextBox1_Enter()
Set myTextBox = TextBox1
End Sub
Private Sub TextBox2_Enter()
Set myTextBox = TextBox2
End Sub
Private Sub SendStringToTextBox(Value As String)
Dim txtLeft As String
Dim txtRight As String
If (myTextBox Is Nothing) Then Exit Sub
With myTextBox
txtLeft = VBA.Left$(.Text, .selStart)
txtRight = VBA.Right$(.Text, Len(.Text) - .selLength - .selStart)
.Text = txtLeft & Value & txtRight
.selStart = Len(txtLeft) + 1
End With
End Sub