passing an object

G

Guest

Hello.

I have several textboxes that I'm going to need to limit the text in to a
specific number of rows... not all the same number of rows... dependent upon
which box it is.

I have the limiting code working reasonably well for a give box, but would
like to write that code into a subroutine that I pass the textbox object, and
the row limit.

I've tried several things, but so far, I either get a type mismatch on the
call, or a message that the object doesn't support that property (LineCount
property of the textbox) in the subroutine itself.

Here is the calling routine:

Private Sub txtGenResp_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal
Shift As Integer)

sbLimitText txtGenResp, 9

End Sub

and the routine called:

Sub sbLimitText(txtBox As OLEObject, intRowLimit As Integer)

If txtBox.LineCount > intRowLimit Then

While txtBox.LineCount > intRowLimit

txtBox.Text = Left(txtBox.Text, txtBox.TextLength - 2)

Wend

End If

That is passing the default property of the textbox object, it's text. I
need it to pass the object itself.

Could someone point me to the error of my ways?
Mark
 
A

arthurjr07

Sub sbLimitText(txtBox As Object, intRowLimit As Integer)


If txtBox.LineCount > intRowLimit Then


While txtBox.LineCount > intRowLimit


txtBox.Text = Left(txtBox.Text, txtBox.TextLength - 2)


Wend


End If
End Sub


HTH
Arthur
 
G

Guest

Thanks. I thought I had tried that (the 'As Object'). Actually, I'm sure I
did, but I must not have tried it with the right calling syntax.

I just tried again, and this time it's working fine.

Thank you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top