Jump to content

Getting user's input from input box


Recommended Posts

For some reason I can't get the input box to show on screen once the program is started.

This is basically my code: 

procedure TForm1.Form1Click(Sender: TObject);
var
  name : String;
begin
  name := InputBox('Name', 'what is your name?', '');
  ShowMessage(name);
end;

Am I missing something? Is there something I need to add onto uses or simply put, is this the complete incorrect syntax?

Any assistance is much appreciated. Thanks

Link to post
Share on other sites
  • 3 weeks later...
On 6/28/2019 at 10:02 AM, jarto said:

This is new for me. Looks like the InputBox is from DWS. When the code is compiled and run, you can see in the source that InputBox is called but absolutely nothing happens - not even an error.

Very weird.

Alright. Well then is there an alternative to get an input from the user?

Link to post
Share on other sites
  • Administrators
On 7/16/2019 at 9:24 PM, DelphiNoob said:

Alright. Well then is there an alternative to get an input from the user?

A simple solution is Prompt, like @Daniel Eiszelewrote:

  var Answer:=Prompt('Question');
  WriteLn(Answer);

If you want a more beautiful solution, then you can make a form for the input and show it modally. That way you can control everything.

Link to post
Share on other sites
7 hours ago, jarto said:

A simple solution is Prompt, like @Daniel Eiszelewrote:


  var Answer:=Prompt('Question');
  WriteLn(Answer);

If you want a more beautiful solution, then you can make a form for the input and show it modally. That way you can control everything.

Yes this is perfect! I haven't actually came across the prompt yet. Thanks @jarto and @Daniel Eiszele

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...