|
-
May 1st, 2011, 12:33 PM
#1
Thread Starter
New Member
[RESOLVED] passing reference of textBox to function
On my UserForm I have tons of textBox's that I require validating the input on. Instead of repeating this code in all of the _Change() functions I thought it would be best to write a public one and call it the 100 times. Unfortunately I can't figure out how to pass the TextBox reference correctly. Is this possible or not?
On my form I have a txtBox called "txtc2srequest"
The Change function is:
Private Sub txtc2srequest_Change()
Call ConfirmInput(txtc2srequest, 15, 1)
End Sub
Public Sub ConfirmInput(ByRef CurrentTextBox As TextBox, length As Integer, which As Integer)
If (CurrentTextBox.TextLength < length) Then
CurrentTextBox.BackColor = vbRed
GoTo DONE
ElseIf (CurrentTextBox.TextLength > length) Then
CurrentTextBox.BackColor = vbRed
GoTo DONE
ElseIf (CurrentTextBox.TextLength = length) Then
CurrentTextBox.BackColor = vbWhite
If which Then
bigStringToFields
Else
indivToBigString
End If
DONE:
End Sub
I get a "Type Mismatch Error 13" and the line is the Call ConfirmInput line. When I mouse-over txt2c2srequest it gives me the value of txtc2srequest.Value and doesn't act like a "TextBox" or larger data type.
Help!
Thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|