How you do this would depend on what you intend doing with those
variables. If you wanted to use them immediatley in another macro then
you could do it like this:
In the form module:
Private Sub CommandButton1_Click()
Dim Var1 As String
Dim Var2 As String
Dim Var3 As String
Var1 = Me.TextBox1.Text
Var2 = Me.TextBox2.Text
Var3 = Me.TextBox3.Text
Call other(Var1, Var2, Var3)
Unload Me
End Sub
In a normal module:
Sub other(str1 As String, str2 As String, str3 As String)
MsgBox "The values are: " & Chr(10) & str1 & _
Chr(10) & str2 & Chr(10) & str3
End Sub
If you wanted these values to be available to a procedure that will be
called at some point later in the same session then you need to declare
the global public variables. This must be done in a standard module at
the top in the declarations section eg:
Option Explicit
Public Var1 As String
Public Var2 As String
Public Var3 As String
Your form code would then be:
Private Sub CommandButton1_Click()
Var1 = Me.TextBox1.Text
Var2 = Me.TextBox2.Text
Var3 = Me.TextBox3.Text
Unload Me
End Sub
and later in a seperate macro you could refer to the variables like this:
Sub getvals()
MsgBox "The values are: " & Chr(10) & Var1 & _
Chr(10) & Var2 & Chr(10) & Var3
End Sub
Finally if you want the values to be available after closing and opening
the book then you should save the values to cells on a worksheet
(possibly hidden) and then reference those cells later eg:
Private Sub CommandButton1_Click()
With Sheets("FormData")
Range("A1").Value = Me.TextBox1.Text
Range("A2").Value = Me.TextBox2.Text
Range("A3").Value = Me.TextBox3.Text
End With
Unload Me
End Sub
Hope this helps
Rowan