Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. " wrote: 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
2 Label Options - Forms Object vs Control Box Object | Excel Discussion (Misc queries) | |||
Confusion about how the Window object fits into the Excel object model | Excel Programming | |||
Passing a named range to a chart/series object | Excel Programming | |||
Creating Object Variables - and passing them as arguements | Excel Programming |