Display a dialog that asks for user text input, with default Dialogs unit
 function InputBox ( const Caption, Prompt, Default : string ) : string;
The InputBox function displays a simple dialog box with the given Caption and Prompt message. It asks the user to enter data in a text box on the dialog. A Default value is displayed in the text box.
If the user presses OK, the default or user entered data is stored in the return string, otherwise an empty string is returned.
If the user cancels the dialog, then the return value is the default string.
Use to ask the user for a data value, where you can give a sensible default value, to save the user unnecessary typing.
Related commands
InputQuery Display a dialog that asks for user text input
PromptForFileName Shows a dialog allowing the user to select a file
ShowMessage Display a string in a simple dialog with an OK button
ShowMessageFmt Display formatted data in a simple dialog with an OK button
ShowMessagePos Display a string in a simple dialog at a given screen position
 Author links

 Buy Website Traffic at

 Buy Proxies at
 Download this web site as a Windows program.

Example code : Keep asking the user for their city with a default
// Full Unit code.
// -----------------------------------------------------------
// You must store this code in a unit called Unit1 with a form
// called Form1 that has an OnCreate event called FormCreate.
unit Unit1;
  Forms, Dialogs;
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
Form1: TForm1;
{$R *.dfm} // Include form definitions
procedure TForm1.FormCreate(Sender: TObject);

  value : string;

  // Keep asking the user for their town
    value := InputBox('Test program', 'Please type your town', 'Cardiff');
  until value <> '';

  // Show their name
  ShowMessage('Your town is '+value);
Hide full unit code
   A dialog is displayed asking for the user city,
   with Cardiff given as the initial value.
   If the user just hits OK, then :
   Your town is Cardiff
   is then displayed
Delphi Programming Neil Moffatt 2002 - 2017. All rights reserved.  |  Home Page