
option button control array - won't work
Hi Mark!
There are too many questions about your problem:
1. Which version of VB do you use (i suppose 4 or 5 becaue you mentioned
a "public" variable)?
2. How do you show the form? Modal or modeless?
3. Do you invoke the option-button's click-event yourself by setting the
value of one of them to "true"?
4. Should the form immediatelly disappear after clicking one of the
buttons, or should it contain Ok- and Cancel-Buttons?
5. Where is the "terrain"-variable defined (public could also be in a
BAS-module)?
=====
Anyway, i would do it this way:
I suppose your form is a modal form because you hide it after the
click-event. Whenever you show a modal dialog, you should create a
public method in the form:
e.g. "Public Function Dialog (Parameters ...) As Boolean"
The function's return value shows whether the dialog was cancelled. (A
user should always be able to cancel a dialog). "True" should tell you
that the dialog was successful. In this case your only parameter tells
the calling procedure which option was selected in your options-form.
And just this value can be supplied by your options-form in the normally
contained OK-button's click-event.
I guess you don't want to be able to cancel the form, i.e. as soon as
you click one of the option-buttons, the form should disappear. In this
case you should do the following steps in the Dialog-Function:
1. Set a form-global boolean-variable ("mIgnoreClick") to true.
2. Load Me
(3. if you want to preselect an option-button (.value): do it here)
4. Set mIgnoreClick to false.
In the option-click-event you should exit the procedure when
mIgnoreClick is true.
I can't explain the click-event when using the normal
"OptionButton"-control-class - if you don't raise it yourself by code.
=====
And two more things:
First, you should move the "frmWilderness.Hide"-Code past the "End
Select"-Statement. Second, please use only "Hide" or "Me.Hide" because
you then will never mix up different instances of one form, because
"frmWilderness" is a form-class AND an "automatic" global variable. Even
if that's probably no problem with your form.
AZ, Germany
=====
Mark Pawelek schrieb:
Quote:
> I'm trying to use a form only to set one of 5 options. The form only
> has an option button control array on it.
> How do I pass the value back to the first form that invoked this
> second form ?
> (I'm using a public variable [terrain] to do this. - but it doesn't
> work as I want it to.]
> When the form is activated (or shown) the click event for optTerrain
> is also activated (without having clicked an option) - this has the
> effect of placing the value of the default button in the terrain
> variable. I only want this variable changed when I click.
> How do I load the form with an option button array in it without this
> happening?
> Do I need to use a form to bring up a new set of options? What is the
> most common way to enter an option?
> Note: I added a command button to the form and set the focus to it
> when the form was activated but this had no effect - the option
> button's click event was still activated mearly on loading the form -
> why is this happening?
> The MS manual doesn't say much about control arrays - and I'm not a
> professional so I have no one to help me. Should I ring the b*****ds
> up and demand that they tell me what to do? Would they? - I have the
> licence but it's nearly a year old.
> Private Sub optTerrain_Click(Index As Integer)
> Select Case Index
> Case 0
> Terrain = Index
> frmWilderness.Hide
> Case 1
> Terrain = Index
> frmWilderness.Hide
> Case 2
> Terrain = Index
> frmWilderness.Hide
> Case 3
> Terrain = Index
> frmWilderness.Hide
> Case 4
> Terrain = Index
> frmWilderness.Hide
> End Select
> End Sub