Minggu, 30 Juni 2013

Re: [ExcelVBA] loop with userform

 


Torstein,
You close the form... and thus return to the calling code... with ...
Unload Me
... in the form code.

But.... hehehe... you probably want to return what's been typed in to the calling code code and guess what... Userforms don't return anything.

And of course there are ways to do this.

The cleanest way IMHO is to Hide the form instead of unloading it. The forms objects are still available and their values can be picked up.

Assuming a form called UserForm1 with a textbox called TextBox1 and a button called CommandButton1 ... In the calling code....

UserForm1.Show
MsgBox UserForm1.TextBox1.Text
Unload UserForm1

In the Click event for the Command button...

Me.Hide

Clicking the command button will hide the form and return to the calling code.

HTH
Lisa

Sent: Sun, Jun 30, 2013 8:56 am

Subject: [ExcelVBA] loop with userform

i have a loop with an inputbox

for i = 1 to 25

svar = inputbox("answer?")

next i

I want to replace the inputbox with an userform, which I'm not familiar with.

How can I return from the userform to the loop when the user has written his
answer?

Thank you!

Regards

Torstein

[Non-text portions of this message have been removed]

__._,_.___
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (2)
Recent Activity:
----------------------------------
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.

----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA

----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com

----------------------------------
.

__,_._,___

Tidak ada komentar:

Posting Komentar