Tengo una macro teclado numérico
Tengo un teclado numérico en un userform que rellena un textbox. Tengo 2 textbox y lo que ocupo es que ese teclado me sirva para para poder escribir ya sea en uno o en el otro al darle click al texbox que deseo.
No logro conseguirlo. Solo me escribe en uno o en los 2 al mismo tiempo y no quiero crear 2 teclado para cada textbox.
Private Sub cmd0_Click()
Clear
Text1.Text = Text1.Text & "0"
End Sub
Private Sub cmd1_Click()
Clear
Text1.Text = Text1.Text & "1"
End Sub
Private Sub cmd2_Click()
Clear
Text1.Text = Text1.Text & "2"
End Sub
Private Sub cmd3_Click()
Clear
Text1.Text = Text1.Text & "3"
End Sub
Private Sub cmd4_Click()
Clear
Text1.Text = Text1.Text & "4"
End Sub
Private Sub cmd5_Click()
Clear
Text1.Text = Text1.Text & "5"
End Sub
Private Sub cmd6_Click()
Clear
Text1.Text = Text1.Text & "6"
End Sub
Private Sub cmd7_Click()
Clear
Text1.Text = Text1.Text & "7"
End Sub
Private Sub cmd8_Click()
Clear
Text1.Text = Text1.Text & "8"
End Sub
Private Sub cmd9_Click()
Clear
Text1.Text = Text1.Text & "9"
End Sub
Private Sub cmdc_Click()
Form_Load
End Sub
Private Sub cmdce_Click()
Text1.Text = ""
End Sub
Private Sub cmdmc_Click()
M = 0
lblmem.Caption = ""
End Sub
Private Sub cmdsign_Click()
If blnsign = False Then
Text1.Text = "-" & Text1.Text
blnsign = True
Else
Text1.Text = Val(Mid(Text1.Text, 2))
blnsign = False
End If
End Sub
Private Sub cmdadd_Click()
Cal
Flag = "add"
End Sub
Private Sub cmdequal_Click()
Select Case Flag
Case "add"
C = A + Val(Text1.Text)
Text1.Text = C
Case "divide"
C = A / Val(Text1.Text)
Text1.Text = C
Case "multiply"
C = A * Val(Text1.Text)
Text1.Text = C
Case "minus"
C = A - Val(Text1.Text)
Text1.Text = C
End Select
Flag = ""
A = 0
B = 0
C = 0
End Sub
Private Sub cmdsqrt_Click()
Text1.Text = Sqr(Text1.Text)
End Sub
Private Sub Form_Load()
'mnuItemPaste.Enabled = False
Text1.Text = ""
A = 0
B = 0
C = 0
M = 0
Flag = ""
blnsign = False
Cl = False
End Sub
Private Sub mnuItemCopy_Click()
mnuItemPaste.Enabled = True
End Sub