我想判断窗体内的edit,combobox组件是否为空值,如果为空,提示,我想用一个函数或过程,可是我写的不成功,不对,有哪位大侠能够写一个给小弟参考一下,写的全一点最好有注释,多谢了??
解决方案 »
- 我的程序是c/s框架的,每次更新程序太麻烦,请问能不能自动更新啊?
- 关于字符串的识别问题!
- 为什么我用StringToWideChar总不成功呢?
- 求SQL语句,如何查询距离给定日期最近的一组记录?
- 各位,在activeform里面用OpenDialog为什么不行呢?,没有别得办法了么?
- 有关Delphi控件的问题
- 请问哪位有Delphi做的公告板源码?
- cxgrid的默认把0.1显示为.1,0没有显示出来
- ActivX的注册问题,请各位高手不吝赐教!
- 关于随机分配数据的问题!!
- 请问谁有在DLL使用WINSOCK API接收消息的例子?
- 请问谁有在DLL用WINSOCK API函数写的收消息的例子!
i : Integer;
begin
for i := 0 to Self.ControlCount -1 do
begin
if self.Controls[i] is TEdit then
begin
if TEdit(Controls[i]).Text = '' then
showMessage(Controls[i].Name + ' is empty');
continue;
end;
if self.Controls[i] is TComboBox then
begin
if TComboBox(Controls[i]).Text = '' then
showMessage(Controls[i].Name + ' is empty');
continue;
end;
end;
end;
i : Integer;
begin
for i := 0 to ComponentCount - 1 do
begin
if Components[i] is TEdit then
begin
if (Components[i] as TEdit).Text= '' then
begin
ShowMessage((Components[i] as TEdit).Name +'is Null!')
Continue;
end;
end;
if Components[i] is TComboBox then
begin
if (Components[i] as TComboBox ).Text= '' then
begin
ShowMessage((Components[i] as TComboBox ).Name +'is Null!')
Continue;
end;
end;
end;
end;
i : Integer;
begin
for i := 0 to Self.ControlCount -1 do
begin
if self.Controls[i] is TEdit then
begin
if TEdit(Controls[i]).Text = '' then
showMessage(Controls[i].Name + ' is empty');
continue;
end;
if self.Controls[i] is TComboBox then
begin
if TComboBox(Controls[i]).Text = '' then
showMessage(Controls[i].Name + ' is empty');
continue;
end;
end;
end;
continue 是继续得意思,如果continue后面还有别的代码的话,但碰到了continue 的话,就会跳过去即不执行后面的代码,而进行i+1操作
begin
If Edit1.Text='' then
showmessage('Edit1 is empty!');
for i:=0 to ComboBox1.Items.Count-1 do
If ComboBox1.Items[i]='' then
showmessage('ComboBox1 is empty!');
end;
函数:
function CheckIfInput(pcontrol:TEDIT; const pmsg:string):string;
begin
if length(pcontrol.text)=0 then
begin
application.MessageBox(pchar(pmsg+'为数据必录项,请您输入之!'),pchar('信息提示'),MB_OK);
pcontrol.SetFocus ;
checkifinput:='error';
end;
end;
调用:
if checkifinput(edit1,'姓名')='error' then exit;