Passing Userform Control to Subroutine

  • Follow


I want to pass values from a userform textbox to a subroutine by reference so 
that the subroutine can pass back the result into the textbox. 

doEqual tbResult1.Value, tbInput1.Value

Private Sub doEqual(resultAmt, inAmt)

This runs OK and debug "watch" values show the correct amount in resultAmt 
and InAmt, but tbResult1.Value remains unchanged. Is this a syntax issue, 
or???

TIA,

Phil
0
Reply Utf 2/26/2010 6:09:02 PM

Private Sub doEqual(resultAmt, tbx As MSForms.TextBox)
tbx.text  = "Amount = " & resultAmt

In the calling procedure pass a referent to the textbox, if that's in the 
parent userform -
Call doEqual(123, me.Textbox1)

Regards,
Peter T


"cellist" <cellist@discussions.microsoft.com> wrote in message 
news:334EB9E2-DEE8-4ADE-8D29-0C8E46B989AE@microsoft.com...
>I want to pass values from a userform textbox to a subroutine by reference 
>so
> that the subroutine can pass back the result into the textbox.
>
> doEqual tbResult1.Value, tbInput1.Value
>
> Private Sub doEqual(resultAmt, inAmt)
>
> This runs OK and debug "watch" values show the correct amount in resultAmt
> and InAmt, but tbResult1.Value remains unchanged. Is this a syntax issue,
> or???
>
> TIA,
>
> Phil 


0
Reply Peter 2/26/2010 8:18:59 PM


Peter,

Thanks for your help, that clears it up for me.

Regards,

Phil

"Peter T" wrote:

> 
> Private Sub doEqual(resultAmt, tbx As MSForms.TextBox)
> tbx.text  = "Amount = " & resultAmt
> 
> In the calling procedure pass a referent to the textbox, if that's in the 
> parent userform -
> Call doEqual(123, me.Textbox1)
> 
> Regards,
> Peter T
> 
> 
> "cellist" <cellist@discussions.microsoft.com> wrote in message 
> news:334EB9E2-DEE8-4ADE-8D29-0C8E46B989AE@microsoft.com...
> >I want to pass values from a userform textbox to a subroutine by reference 
> >so
> > that the subroutine can pass back the result into the textbox.
> >
> > doEqual tbResult1.Value, tbInput1.Value
> >
> > Private Sub doEqual(resultAmt, inAmt)
> >
> > This runs OK and debug "watch" values show the correct amount in resultAmt
> > and InAmt, but tbResult1.Value remains unchanged. Is this a syntax issue,
> > or???
> >
> > TIA,
> >
> > Phil 
> 
> 
> .
> 
0
Reply Utf 2/26/2010 9:53:01 PM

2 Replies
807 Views

(page loaded in 0.096 seconds)

Similiar Articles:
















7/26/2012 4:47:12 AM


Reply: