how to return a string value from a UserForm? 
Author Message
 how to return a string value from a UserForm?

I want to return a numeric string value from a UserForm but can't quite
figure out how to do it from the VB help files.

I want the user to be able to enter a value in a box and click OK to
proceed, at which point the dialog should be closed and the value they
entered returned to a defined string called ChapterValue that will then be
processed in the macro.

Could someone please point me in the right direction? Thanks,

Abe



Sun, 18 Jan 2004 02:48:03 GMT  
 how to return a string value from a UserForm?
Hi Abe,

Quote:
> I want to return a numeric string value from a UserForm but can't quite
> figure out how to do it from the VB help files.

> I want the user to be able to enter a value in a box and click OK to
> proceed, at which point the dialog should be closed and the value they
> entered returned to a defined string called ChapterValue that will then be
> processed in the macro.

An example - UserForm1 with a CommandButton1 and TextBox1

Code in UserForm module:
--------------------------------------------------

Private Sub CommandButton1_Click()

    Me.hide

End Sub

--------------------------------------------------

Code in code module:
--------------------------------------------------

Public Sub Macro1()

    Dim ChapterValue As String

    UserForm1.Show

    ChapterValue = UserForm1.TextBox1.Text

    Unload UserForm1

    MsgBox ChapterValue

End Sub

--------------------------------------------------

Hope this helps.
ibby

Please post replies or follow-ups to the **newsgroup** so that participants
may benefit or contribute.



Sun, 18 Jan 2004 13:43:35 GMT  
 how to return a string value from a UserForm?
Ibby,

I was trying for the life of me to figure out where the heck the code
was supposed to go to define clicks, and I finally discovered that I
could right-click on the form and choose "view code"--thanks in large
part to your mention of "code in UserForm module". I'll start playing
with this and see how far I get. Can you recommend good online resources
for working with UserForms? Real-world examples, both simple and
complex, would be very helpful. Though I think I'll be better able to
grasp the examples in the VBA help file now. Thanks!

Abe



Mon, 19 Jan 2004 10:40:27 GMT  
 how to return a string value from a UserForm?
Abe,

I have bought Word 2000 Developer's Handbook, by Guy Hart-Davis. 1250 pages
of useful information. The codes and User forms from the book are supposed
to be on the web at www.sybex.com



Mon, 19 Jan 2004 20:08:11 GMT  
 how to return a string value from a UserForm?

Quote:

> I have bought Word 2000 Developer's Handbook, by Guy Hart-Davis. 1250 pages
> of useful information. The codes and User forms from the book are supposed
> to be on the web at www.sybex.com

Thanks for the reference, Guy. I've been focused on other things
(scripting & c.!) and have not been back here in a while...

Abe



Sun, 08 Feb 2004 15:29:23 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Function to Return String Value of Date

2. how to get a return value from a exe program to DOS (string)

3. How do you remove line feed and carriage return values from a string

4. returning values from a string

5. Returning a string from a function by value?

6. How to handle a string as return value?

7. problem using component with asp page -- result of function not returned, instead original value returned

8. Returning Recordset and Return Value from Command Object

9. Using a value to return a value

10. Main report value<-pass/return->subReport values (ActiveX Designer Component 6.0)

11. Return value and Output values from Stored Procedure

12. Break single string with carriage return into 2 strings

 

 
Powered by phpBB® Forum Software