I have a project with many forms and textboxes. I am trying to create a module that will add a "." (Chr45) in the value.
this is the code on the userform. the textbox name changes throughout the project
Private Sub TextBox4_Exit(ByVal Cancel As msforms.ReturnBoolean)
Run TxtBx_Change
end sub
this is what i have in the module. I suspect it has to do with knowing the actual name of the textbox?
the code below is not working, could anyone help?
Private Sub TxtBx_Change()
Dim CtlTxt As TextBox
Dim Str1 As String
Dim Str2 As String
Str1 = Mid(CtlTxt.Value, 1, 2)
Str2 = Mid(CtlTxt.Value, 3, 4)
If CtlTxt.TextLength = 4 Then
CtlTxt.Value = Str1 & Chr(45) & Str2
End If
End Sub
it is a basic code i am just starting to work with. I will be expanding the code as soon as i figure out this simple task
Bookmarks