STAAD.Pro Help

OS. To dimension the variables and add initial values in the dialog

You must dimension all the values you will use in the program. Further, it's a good idea to populate the dialog with initial values for the user.

  1. Select the automatically generated line of code Dialog dlg (i.e., line 23) and delete the line contents.
  2. With your cursor after the line of code Dim dlg as UserDialog, type the following to dimension the variables in use:
        Dim dlgResult As Integer
        Dim crdx As Double
        Dim crdy As Double
        Dim crdz As Double
        Dim n1 As Long
        Dim n2 As Long
        Dim i1 As Long
        Dim s1 As Long
    Note: As you being to type, the IntelliSense will provide options for the variable types. You can make use of the IntelliSense to help quickly complete lines and reduce typos in your source code.
  3. Type a single quote mark followed by Initialization. The single quote mark is used to denote a comment. It is best practice to add clear comments to document your source code.
  4. Type the following values to populate the dialog input fields:
        dlg.clmn = "3"
        dlg.row = "5" = "3"
        dlg.wdth = "5"
  5. Type the following commands to open the dialog upon starting the macro. You'll also add a comment and a debugging command which is helpful for resolving any issues with your macro.
        'Popup the dialog
        dlgResult = Dialog(dlg)
  6. Type the following command to capture the result of the user action in the dialog:
        If dlgResult = -1 Then 'OK button pressed
            Debug.Print "OK button pressed"
        ElseIf dlgResult = 0 Then 'Cancel button pressed
            Debug.Print "Cancel button pressed"
        End If
    Note: The single quote mark after the world Then also indicates a comment. Comments like this can follow the programming instruction on the same line.

    The EndIf statement is automatically added by the editor to close the If statement if you press <Enter>.

You have now created the general set of instructions to the program what to do with the user action in the form.
You can test the macro now to see the dialog populated with the initialized values. Select the Run tool in the Execute group. The macro dialog opens. Click either OK or Cancel to close it. Neither perform any action at this point other than to log a debug message.
The next step is to have the script then perform the desired actions when the users clicks OK.
Tip: Now is a good time to save the work done to this point.