PDA

View Full Version : Transferring data from one Userform to the next



redhack22
12-06-2009, 07:13 PM
I'm trying to write code that solves an equation based on user input.
But I cannot figure out how to make a Label in a new userform dependent on the variable 'answer' as defined in the userform right before the last one. I just need the final calculation presented in a new userform and not a msgbox.


thanks for any help you can give me. the variables are all defined in the module.

redhack22
12-06-2009, 07:15 PM
picture of actual project:

hphotos-snc3.fbcdn.net/hs070.snc3/13769_1181546185891_1445280033_30511844_1957890_n.jpg

Paul_Hossler
12-06-2009, 07:39 PM
One way:

Add 2 Userforms, put a Textbox on 1, and a Label on 2

On the Userform1 code module, put


Option Explicit
Private Sub cbDone_Click()
Call UserForm2.Hide
Unload UserForm2

Call UserForm1.Hide
Unload UserForm1

End Sub
Private Sub tbInput_Change()
UserForm2.labOutput.Caption = UserForm1.tbInput.Text
End Sub
Private Sub tbInput_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Call tbInput_Change
End Sub



I added a worksheet button, but the .Show code can go anywhere (almost)


Private Sub CommandButton1_Click()
Load UserForm2
Call UserForm2.Show(vbModeless)

Load UserForm1
Call UserForm1.Show(vbModeless)
End Sub


Paul