Promotic
WikipediaLinkedInYoutubeTwitterFacebook

InputBox - method of object Pm

Description:
Entering the value (using the input window) of one or more variables (variables of the array type) by the user.

This method is obsolete (but functional) and is replaced by the PmForm object.

Syntax:
InputBox(sDlgTitle As String, sDlgStyle As String, vItemValue As Variant, vItemName As Variant, vItemType As Variant, [vItemAttr1 As Variant], [vItemAttr2 As Variant]) As Boolean
Calling:
val = Pm.InputBox("Title", sDlgStyle, vItemValue, vItemName, vItemType, vItemAttr1, vItemAttr2)
Parameters:
sDlgTitle(String) Title of the input window
sDlgStyle(String) Style of the window. Example: "left:100;top:200;z-order:topmost;button-cancel:no;"
left - Position of the left window side relative to the whole screen (in pixels). For the position definition it is possible to use, for example, PmiItem.ScreenX or PmPanel.ScreenX properties.
right - Position of the right window side relative to the whole screen (in pixels). Don't set if left is specified. Unless left nor right is specified, then the window will be centered horizontally.
top - Position of the top window side relative to the whole screen (in pixels). For the position definition it is possible to use, for example, PmiItem.ScreenY or PmPanel.ScreenY properties.
bottom - Position of the bottom window side relative to the whole screen (in pixels). Don't set if top is specified. Unless top nor bottom is specified, then the window will be centered vertically.
z-order - topmost value means that the window will be on top of all Windows windows.
button-cancel - Appearance of the Cancel button. The no value means that the button won't be seen.
vItemValue[for read and write] (Variant) variable (or more variables) for entering the value
vItemName(Variant) Description (or array of descriptions) to the vItemValue variable
vItemType(Variant) text (or array of texts) identifying the type of the entered value:
"string" - Text is entered (String data type). The graphic form for entering is the EditBox.
vItemAttr1 (Integer type) defines the maximum number of visible characters (i.e. it affects the width of the EditBox). The maximum length of the entered text is 1000 characters. If the number of visible characters is less than the number of entered characters, then it is possible to scroll in the input box by the cursor.
vItemAttr2 is not used - don't use it or set it to Empty.
"int" - An integer (Long, Integer or Byte data type) is entered. The graphic form for entering is the EditBox.
vItemAttr1 (Long type) defines the low limit of the entered value (if it hasn't to be checked, don't set it or set it to Empty).
vItemAttr2 (Long type) defines the high limit of the entered value (if it hasn't to be checked, don't set it or set it to Empty).
"real" - The real number (Single or Double data type) is entered. The graphic form for entering is the EditBox.
vItemAttr1 (Double type) defines the low limit of the entered value (if it hasn't to be checked, don't set it or set it to Empty).
vItemAttr2 (Double type) defines the high limit of the entered value (if it hasn't to be checked, don't set it or set it to Empty).
"bool" - true or false value (Boolean data type) is entered. The graphic form for entering is the CheckBox.
vItemAttr1 and vItemAttr2 is not used - don't set it or set it to Empty.
"enum" - The selection from several predefined options. Non-negative integer (Long data type) is entered. It represents the index (zero-based index) of the selection from several options. The graphic form for entering is the ComboBox.
vItemAttr1 (Integer type) defines the maximum number of visible characters (i.e. it affects the width of the ComboBox).
vItemAttr2 (String type) defines options. It is the text of words separated by the | character (i.e. pipe sign), for example "option1|option2".

The value in the vItemValue (of Long type) defines a word at the beginning that will be pre-selected. There is the index of the selected word at the end.

"password" - Text (String data type) is entered as a password. The graphic form for entering is the EditBox and instead of entering characters only stars * can be seen.
vItemAttr1 and vItemAttr2 have the same meaning as for the "string" type.
"static" - It doesn't serve for entering. Only static text can be seen that is in the vItemName parameter. There can be and they are active characters "new line" in this text (see vbCrLf constant) and it occurs to line breaking if the text is too wide. The vItemValue parameter is not used - set it to Empty.
vItemAttr1 (String type) defined the appearance of the static text. If not set of set to Empty, the text is aligned to left. If the "center" text is set, the text is centered.
vItemAttr2 is not used - don't set it or set it to Empty.
vItemAttr1[optional] (Variant) The first attribute (or array of attributes) whose meaning changes according to vItemType
vItemAttr2[optional] (Variant) The second attribute (or array of attributes) whose meaning changes according to vItemType
Return Values:
true - If the InputBox has been closed by the OK button
false - If the InputBox has been closed by the Cancel button
Note:
The PmPanel object can be use for creating more complex imput windows opened by the PmPanel.OpenView method.
 
This method is not so far functional for Web Panels.
Example1:
Simple usage of the method for entering single value:
Dim val
val = 3.14
If Pm.InputBox("Set value", "", val, "Power", "real", 0, 100) then
  'When the InputBox has been closed by the OK button
  Pm.Debug "val=" & val
End If
Example2:
The InputBox can be used like in the Pm.MessageBox only for the text representation. But the InputBox is more common and for example coordinates of the window location can be entered:
Dim sText
sText = "Error in starting the security mode" & vbCrLf & "Temperature out of the permitted range"
Pm.InputBox "Critical error", "button-cancel:no;left:300;top:300;", Empty, sText, "static", "center"
Example3:
Entering one real variable in the range of <40, 80> into the PmNumber object with the "Number" name. The InputBox is called from the event of a graphic item (i.e. the pMe parameter is the graphic item) and it will be located on the left (in framed line - on the right) from this item:
Dim val, oNumber, sStyle
Set oNumber = pMe.Pm("/Number")
val = oNumber.Value
sStyle = "right:" & pMe.ScreenX & ";top:" & pMe.ScreenY & ";"
' sStyle = "left:" & pMe.ScreenX+pMe.Dx & ";top:" & pMe.ScreenY & ";"
' sStyle = "left:" & pMe.PmPanel.ScreenX+100 & ";top:" & pMe.PmPanel.ScreenY+100 & ";"
If Pm.InputBox("Set value", sStyle, val, "Power", "real", 40, 80) Then
  'When the InputBox has been closed by the OK button
  oNumber.Value = val
End If
Example4:
Entering multiple values, the window appears "Always on top" and in the midst of the screen:
Dim arrValue, arrName, arrStyle, arrAttr1, arrAttr2, ret
arrValue = Array("Sort", true, 2, 0.4, Empty, 1)
arrName = Array("Name of the process", "Enabled", "Number of repetitions", "Percentage of success rate", "", "Mode selection")
arrStyle = Array("string", "bool", "int", "real", "static", "enum")
arrAttr1 = Array(20, Empty, 0, 0, Empty, 20)
arrAttr2 = Array(Empty, Empty, 10, 1, Empty, "Batch|Continuous|Discrete")
ret = Pm.InputBox("Input data", "z-order:topmost;", arrValue, arrName, arrStyle, arrAttr1, arrAttr2)
If ret Then
  'When the InputBox has been closed by the OK button
  Pm.Debug "Name of the process:" & arrValue(0)
  Pm.Debug "Enabled:" & arrValue(1)
  Pm.Debug "Number of repetitions:" & arrValue(2)
  Pm.Debug "Percentage of success rate:" & arrValue(3)
  Pm.Debug "Mode selection:" & arrValue(5)
End If
Navigation:
 
- Pm
 
- Abs
- Cos
- E
- Exp
- InputBox
 
 
- LN2
- PI
- Pow
- Sin
- Tan
© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice