Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 989
Default passing an object

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default passing an object

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 989
Default passing an object

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
2 Label Options - Forms Object vs Control Box Object Awrex Excel Discussion (Misc queries) 3 July 17th 09 07:10 PM
Confusion about how the Window object fits into the Excel object model Josh Sale Excel Programming 11 April 15th 05 06:08 PM
Passing a named range to a chart/series object CraigBarton Excel Programming 0 May 24th 04 03:45 AM
Creating Object Variables - and passing them as arguements Ian Stanborough Excel Programming 3 November 11th 03 02:28 PM


All times are GMT +1. The time now is 08:16 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"