ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Passing Userform Control to Subroutine (https://www.excelbanter.com/excel-programming/440025-passing-userform-control-subroutine.html)

cellist

Passing Userform Control to Subroutine
 
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

Peter T

Passing Userform Control to Subroutine
 

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" wrote in message
...
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




cellist

Passing Userform Control to Subroutine
 
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" wrote in message
...
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



.



All times are GMT +1. The time now is 03:34 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com