Hello, I am trying to find a way to replace part of a string in a textbox. I have the user enter a job number and I have it verify they have entered the side they are working on which is just 2 choices "-TOP" or "-BOTTOM". So when they work on the same job number, I would like to replace one for the other. If they have this: "98-1002-600-TOP" and are finished, I want to press the button and replace just the -TOP with -BOTTOM. Also work in the opposite way if they start BOTTOM first, then it will change to -TOP. Any ideas on this? Your help is greatly appreciated.
Here is the code I have for checking the end of the job number.... Now I just need to know how to replace one for the other when I change jobs.
'check for -top / -btm entry in field
Private Sub txtCCA_Exit(ByVal Cancel As MSForms.ReturnBoolean)
With Me.txtCCA
If Len(.Value) Then
If CheckIt(.Value) Then
MsgBox "*Enter -TOP or -BTM *", vbInformation, .Value
Cancel = True
End If
End If
End With
End Sub
'check for -top / -btm entry
Private Function CheckIt(ByVal txt As String) As Boolean
With CreateObject("VBScript.RegExp")
.Pattern = "\d*(-TOP|-BTM)\d*"
.ignorecase = True
CheckIt = Not .test(txt)
End With
End Function
Bookmarks