Delphi 7-如何使用Inputbox [英] Delphi 7 - how to use Inputbox

查看:291
本文介绍了Delphi 7-如何使用Inputbox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编程一个程序,您必须在其中输入密码才能访问程序的min features。但是,如果您在输入框上单击取消,我的程序将显示错误消息。所以我想知道是否有人知道我如何做到这一点,因为使用Messagedlg我知道您使用IF。但是,如何使用InputBox使其正确呢?

I am programming a program where you have to enter a password into a InputBox to gain access to the programs min features . But I have a problem if you click on cancel on the inputbox my program gives a error message . So i wanted to know if any one know how I can get that right because with the Messagedlg I know you use IF . But how can I get it right with a InputBox ?

推荐答案

InputBox()如果取消了对话框,则返回空白字符串,例如:

InputBox() returns a blank string if the dialog is canceled, eg:

var
  Pass: String;

Pass := InputBox('Password needed', 'Enter the password:');
if Pass <> '' then
begin
  // use Pass as needed...
end;

或者,使用 InputQuery()代替,返回 Boolean 来指示对话框是否被取消,例如:

Alternatively, use InputQuery() instead, which returns a Boolean to indicate whether the dialog was canceled or not, eg:

var
  Pass: String;

if InputQuery('Password needed', 'Enter the password:', Pass) then
begin
  // use Pass as needed...
end;

这篇关于Delphi 7-如何使用Inputbox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆