Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm hungup trying to pass a combo box to a procedure with the 'Type Mismatch'
error. Here's a sample of what I'm trying to do. I think I'm passing the string title of the cbox instead of the object. Private Sub UserForm_Initialize() Debug.Print "txtBox1 Name = " & Me.txtBox1.Name Call PassTxtBox(txtBox1) End Sub Private Sub PassTxtBox(ByRef itxtBox As TextBox) Debug.Print "Passed Text Box Name = " & itxtBox.Name End Sub |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hokievandal wrote:
I'm hungup trying to pass a combo box to a procedure with the 'Type Mismatch' error. Here's a sample of what I'm trying to do. I think I'm passing the string title of the cbox instead of the object. Private Sub UserForm_Initialize() Debug.Print "txtBox1 Name = " & Me.txtBox1.Name Call PassTxtBox(txtBox1) End Sub Private Sub PassTxtBox(ByRef itxtBox As TextBox) Debug.Print "Passed Text Box Name = " & itxtBox.Name End Sub Excel VBA may be a little different, but in vb6 your syntax seems to work just fine: Option Explicit Private Sub Form_Load() Debug.Print "text1 Name = " & Me.Text1.Name Call PassTxtBox(Text1) End Sub Private Sub PassTxtBox(ByRef itxtBox As TextBox) Debug.Print "Passed Text Box Name = " & itxtBox.Name Debug.Print "Passed Text Box Text = " & itxtBox.Text End Sub [result] text1 Name = Text1 Passed Text Box Name = Text1 Passed Text Box Text = my text Though personally I might leave off both the "Call" keyword and the parentheses from that line (optional syntax) Maybe the problem isn't the call, but in /when/ you're making it. Is the control really fully instantiated by the time of the UserForm_Initialize event? Bob -- |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Private Sub UserForm_Initialize()
Debug.Print "txtBox1 Name = " & Me.txtBox1.Name Call PassTxtBox(txtBox1) End Sub Private Sub PassTxtBox(ByRef itxtBox As msforms.TextBox) Debug.Print "Passed Text Box Name = " & itxtBox.Name End Sub -- HTH Bob Phillips (replace xxxx in the email address with gmail if mailing direct) "Hokievandal" wrote in message ... I'm hungup trying to pass a combo box to a procedure with the 'Type Mismatch' error. Here's a sample of what I'm trying to do. I think I'm passing the string title of the cbox instead of the object. Private Sub UserForm_Initialize() Debug.Print "txtBox1 Name = " & Me.txtBox1.Name Call PassTxtBox(txtBox1) End Sub Private Sub PassTxtBox(ByRef itxtBox As TextBox) Debug.Print "Passed Text Box Name = " & itxtBox.Name End Sub |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Bob Phillips wrote:
Private Sub PassTxtBox(ByRef itxtBox As msforms.TextBox) Cool! I'm just "browsing" here lately, mostly to learn more about Excel's capabilities. My VB expertise can sometimes help in VBA, but in this case it was something else. Thanks! You already helped more than just the OP. Bob (MS-MVP VB, 2000-2006) -- |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Bob,
See my follow-up to Hokievandal for more detail. -- HTH Bob Phillips (replace xxxx in the email address with gmail if mailing direct) "Bob O`Bob" wrote in message ... Bob Phillips wrote: Private Sub PassTxtBox(ByRef itxtBox As msforms.TextBox) Cool! I'm just "browsing" here lately, mostly to learn more about Excel's capabilities. My VB expertise can sometimes help in VBA, but in this case it was something else. Thanks! You already helped more than just the OP. Bob (MS-MVP VB, 2000-2006) -- |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Bobs! Figured it was something simple like that
Ryan "Hokievandal" wrote: I'm hungup trying to pass a combo box to a procedure with the 'Type Mismatch' error. Here's a sample of what I'm trying to do. I think I'm passing the string title of the cbox instead of the object. Private Sub UserForm_Initialize() Debug.Print "txtBox1 Name = " & Me.txtBox1.Name Call PassTxtBox(txtBox1) End Sub Private Sub PassTxtBox(ByRef itxtBox As TextBox) Debug.Print "Passed Text Box Name = " & itxtBox.Name End Sub |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Excel and the MSForms libraries both have "TextBox" objects. Therefore,
TextBox is an ambiguous reference. In this instance, VBA uses the library with a higher priority. Because the Excel library is at a higher priority, the object from this library is used. A textbox user form is not an Excel.TextBox, it is an MSForms.TextBox, so it must be qualified as such. -- HTH Bob Phillips (replace xxxx in the email address with gmail if mailing direct) "Hokievandal" wrote in message ... Thanks Bobs! Figured it was something simple like that Ryan "Hokievandal" wrote: I'm hungup trying to pass a combo box to a procedure with the 'Type Mismatch' error. Here's a sample of what I'm trying to do. I think I'm passing the string title of the cbox instead of the object. Private Sub UserForm_Initialize() Debug.Print "txtBox1 Name = " & Me.txtBox1.Name Call PassTxtBox(txtBox1) End Sub Private Sub PassTxtBox(ByRef itxtBox As TextBox) Debug.Print "Passed Text Box Name = " & itxtBox.Name End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
pass paramter to SQL server stored procedure | Excel Programming | |||
How to pass sheet reference to a procedure | Excel Programming | |||
How to pass a variable from Form back to calling procedure | Excel Programming | |||
Pass switch to Main procedure | Excel Programming | |||
How to pass an Excel range as an argument to a SQL Server stored Procedure | Excel Programming |