View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jim Cone[_2_] Jim Cone[_2_] is offline
external usenet poster
 
Posts: 1,549
Default passing values from form to module


Those "public" variables in class modules are really private.
The module behind a user form is a class module.
All or most controls on a user form and the user form have a "Tag" property (its
a string).
You can assign a value to a tag property and then access it anytime before the
form is unloaded...

textVariable = LaunchForm.Controls("Sludge").Tag
'---
Jim Cone
Portland, Oregon USA
http://www.mediafire.com/PrimitiveSoftware
(create Lottery Numbers - in the free folder)




"c1802362"
wrote in message
...
Hello, all.

I have a programming issue I can’t seem to get a handle on.

I have an application that launches a form (“LaunchForm”) that gives
the user a choice of picking either Radio Button A or B. Picking
either radio button assigns a string variable (“textvariable”) with an
appropriate value (StringA or StringB).

When I try to pass textvariable from the form to the application, it
disappears. Any suggestions? Here’s the basic code:


Option Explicit

Sub RunThisApp()

LaunchForm.Show

Range(“A1”).Value = textvariable

.........more code.....

Unload LaunchForm

End Sub

Here’s the code for LaunchForm

Option Explicit
Public textvariable As String ' I added the public statement to
the form since this is the first appearance of textvariable

Private Sub YesButton_Click()

If ButtonA.Value = True Then
textvariable = "StringA"
End If

If ButtonB.Value = True Then
textvariable = "StringB”
End If

LaunchForm.hide

End Sub

Private Sub CancelButton_Click()
Unload LaunchForm
Exit Sub
End Sub


Art