VB Script - Custom Dialog with Textbox and Dropdown

VB Script - Custom Dialog with Textbox and Dropdown

In this case, we want to create a dialog with a drop-down box and input/text box for numerical input. The values from dialog controls are stored in variables var1 & var2, thus allowing math operations, flow control, etc., from the user's response.  

CODE: 

Dim MyList (2)  'Initialize a static array
MyList (0) = "0.000001"
MyList (1) = "0.000005"
MyList (2) = "0.0000001"
'Create dialog object
Set dlg1 = CreateDialog(16,35,256,89,"Part Material and Temperature")
'Add system buttons
dlg1.Add_OKButton 204,24,40,14
dlg1.Add_CancelButton 204,44,40,14
'Declare variables to get the listbox selection
Dim var1, var2
var1 = 20
var2 = 0 'to select first item by default
dlg1.Add_TextBox 24, 24, 72, 12, var1  'Add a Text Box
dlg1.Add_DropListBox 124,24,72,40,mylist,var2  'Add a drop list box
'Add some static text boxes
dlg1.Add_Text 24,12,75,8,"Part Temperature: (C)"
dlg1.Add_Text 124,12,75,8,"Part CTE: (mm/mm/C)"
Button = ShowDialog ( Dlg1 )  'Show dialog
'Verify drop listbox selections
MsgBox("Temperature = " & var1 &vbCRLF & "DropListbox = " & var2)
Set Dlg1 = Nothing  'Destroy the dialog object after use

    • Related Articles

    • VB Script - Getting Started

      What can I do with VB Scripting? CMM-Manager VB Scripts run in line with program execution and can be used to perform loops and flow control, display custom messages, prompt user for input that then influences program execution - i.e. skip section of ...
    • Parametric Programming - Part Families

      Do you manufacture and inspect Part Families? Meaning, variety of parts having similar overall geometry but with varying dimensional characteristics? Instead of cresting one program for each unique part, you can realize significant time savings by ...
    • VB Script - Variable use for Feature Names and User Notes

      When looping Program steps by use of VB Script loop - i.e. For Loop, Do Until, etc. - Features that have been executed more than one time will automatically be renamed using standard convention as such - Circle1, Circle1...1, Circle1...2, ...
    • Launch CMM-Manager Program using External Command

      It is possible to run another CMM-Manager Program from the External Command operation. This is useful if you'd like to create a simple launching program - i.e. main program that prompts user for next program, and then runs accordingly to user ...
    • VB Script - Calculate Measured Arc Length

      To find the Arc length, you need 3 measurements. A circle (Arc), and a line or point at each of the Arc. From there, construct lines from the center of Circle to Arc's endpoints and report both the diameter of Circle and Angle between two constructed ...