Ask Your Question
0

How do I list the controls in a dialog?

asked 2017-07-21 17:46:05 +0200

vhradice gravatar image

updated 2017-07-21 18:02:58 +0200

Lupp gravatar image

I am debugging some freeware code as an addin to Calc and I am having 2 problems. Here is the subroutine I am having a problem with. When I invoke it I get an error when I try to reset the value of OptionIDontCare. I get the following error: BASIC runtime error. Object variable not set.

Sub OptionIDontCare_Click()
Field = "<" & sOptionIDontCare & ">"
If oDialog1.GetControl("OptionIDontCare").State = True Then
    oDialog1.GetControl("TextFieldOrder").Text = _  
      oDialog1.GetControl("TextFieldOrder").Text + Field & " "
    QIFFields(iCol) = Field
    iCol = iCol + 1
    OptionIDontCare.Value = False
End If
End Sub

I have 2 problems. The first is how do I change the value of OptionIDontCare.State? Are State and Value the same thing? The second is I cannot find the OptionIDontCare control. How can I list the names of the controls in a dialog?

Thank you,
Vince Radice

(Formatting rectified by @Lupp )

edit retag flag offensive close merge delete

Comments

Thank you @Lupp for reformatting the code.

vhradice gravatar imagevhradice ( 2017-07-21 17:58:22 +0200 )edit

2 Answers

Sort by » oldest newest most voted
0

answered 2017-07-21 19:14:58 +0200

Ratslinger gravatar image

Hello @vhradice,

Starting with dialog control names. An actual list won't be much help if you don't know the type of control it is associated with. The easier method is to go to the Basic IDE and select the Dialog control you are dealing with. Then select a control and its information will display in lower left corner view. Example:

image description

Here the option button control was selected & its name is OptionButton1. This will give you the needed names.

Changing values of a control dependent entirely on what type of control you are dealing with. Option Button and Check Box deal with a state meaning On or Off (checkbox has a third state Not Defined). Other controls use either Value or Text to change the data. This depends upon the control and type of data.

So in dealing with a 'Option Button' or 'Check Box', the State would be 1 or True to represent ON and 0 or False to represent OFF.

edit flag offensive delete link more
0

answered 2017-07-22 02:53:32 +0200

librebel gravatar image

updated 2017-07-22 02:56:45 +0200

Hello @vhradice,

To change the State of your optionbutton "OptionIDontCare", you could call:

oDialog.getControl( "OptionIDontCare" ).State = False

To get the list of controls on your dialog, just call its method oDialog.getControls() For example:

Dim i As Integer
For i = 0 To uBound( oDialog.getControls() )
    msgbox oDialog.getControls()( i ).Model.Name
Next i

The variable oDialog should be declared as Object elsewhere in the module, e.g.:

Private oDialog As Object
edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2017-07-21 17:46:05 +0200

Seen: 225 times

Last updated: Jul 22 '17