WildBurrow
New Member
- Joined
- Apr 5, 2021
- Messages
- 41
- Office Version
- 365
- Platform
- Windows
I found the following code that provides the function I need (sorry, I forgot to snag contributor's name).
I'd like to group this code to accommodate multiple text boxes on specific pages on the Userform. While I understand that I can address a specific page with this: "For Each Ctrl In Me.MultiPage1.Pages(2).Controls)", I don't know how to write the code for KeyPress.
I have 25 such text boxes on pages 3, 4, and 5 of the Userform (I know the pages collection is zero-based).
VBA Code:
Private Sub txtPriCO1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Select Case KeyAscii
Case vbKey0 To vbKey9, vbKeyBack, vbKeyClear, vbKeyDelete, _
vbKeyLeft, vbKeyRight, vbKeyUp, vbKeyDown, vbKeyTab
If KeyAscii = 46 Then If InStr(1, txtPriCO1.Text, ".") Then KeyAscii = 0
Case Else
KeyAscii = 0
Beep
End Select
End Sub
I'd like to group this code to accommodate multiple text boxes on specific pages on the Userform. While I understand that I can address a specific page with this: "For Each Ctrl In Me.MultiPage1.Pages(2).Controls)", I don't know how to write the code for KeyPress.
I have 25 such text boxes on pages 3, 4, and 5 of the Userform (I know the pages collection is zero-based).