DlgText$ (function)

Syntax

DlgText$(ControlName$ | ControlIndex)

Description

Returns the text content of the specified control.

Comments

The text returned depends on the type of the specified control:

 

Control Type

Value Returned by DlgText$

 

Picture

No value is returned. A runtime error occurs.

 

Option group

No value is returned. A runtime error occurs.

 

Drop list box

Returns the currently selected item. A zero-length string is returned if no item is currently selected.

 

OK button

Returns the label of the control.

 

Cancel button

Returns the label of the control.

 

Push button

Returns the label of the control.

 

List box

Returns the currently selected item. A zero-length string is returned if no item is currently selected.

 

Combo box

Returns the content of the edit field portion of the combo box.

 

Text

Returns the label of the control.

 

Text box

Returns the content of the control.

 

Group box

Returns the label of the control.

 

Option button

Returns the label of the control.

 

The ControlName$ parameter contains the name of the .Identifier parameter associated with a control in the dialog box template. A case-insensitive comparison is used to locate the specific control within the template. Alternatively, by specifying the ControlIndex parameter, a control can be referred to using its index in the dialog box template (0 is the first control in the template, 1 is the second, and so on).

Example

This code fragment makes sure the user enters a correct value. If not, the control returns focus back to the TextBox for correction.

Function DlgProc(ControlName$,Action%,SuppValue%) As Integer

  If Action% = 2 and ControlName$ ="OK" Then
    If IsNumeric(DlgText$("TextBox1")) Then
      Msgbox "Duly Noted."
    Else
      Msgbox "Sorry, you must enter a number."
      DlgFocus "TextBox1"
      DlgProc = 1
    End If
  End If
End Function

Sub Main()

  Dim ListBox1$()
  Begin Dialog UserDialog ,,112,74,"Untitled",.DlgProc
    TextBox 12,20,88,12,.TextBox1
    OKButton 12,44,40,14
    CancelButton 60,44,40,14
    Text 12,11,88,8,"Enter Desired Salary:",.Text1
  End Dialog
  Dim d As UserDialog
  Dialog d
End Sub

See Also

DlgControlId (function); DlgEnable (function); DlgEnable (statement); DlgFocus (function); DlgFocus (statement); DlgListBoxArray (function); DlgListBoxArray (statement); DlgSetPicture (statement); DlgText (statement); DlgValue (function); DlgValue (statement); DlgVisible (statement); DlgVisible (function).

More information

D