Passing Userform Control to Subroutine

C

cellist

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
 
P

Peter T

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top