View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default Extract text from a "textbox"

Instead of Dim'ming your variables inside the DoStuff procedure (where only
code within the DoStuff procedure can see them), put those declaration
statements inside a standard module (Insert/Module from the VB editor's menu
bar) using Public instead of Dim and ALL procedures in your workbook will be
able to see them, in particular, your DoStuff procedure and any code in your
UserForm. And once you do that, make sure you remove the Dim statements from
the DoStuff procedure (if you leave them there, then those declarations will
take precedence).

Rick Rothstein (MVP - Excel)



"Robert Crandal" wrote in message
...

My code so far looks like this:

'---------------------------------------------------
Sub DoStuff ()

Dim first_name as String
Dim last_name as String

UserForm.Show ' Show form with text boxes

' what goes here?

End Sub
'-------------------------------------------------

The code that shows the userform causes a
userform to be displayed which allows a user to
enter text into Textbox1 and/or Textbox2.

Once a user enters text into either textbox and
closes out the Userform, is it possible to get
the values from the textboxes and store them
in the string variables above in the DoStuff()
subroutine??

Thank you!

Robert