您好我有一个delphi问题,一直在吃我,我需要帮助 [英] Hello I have a delphi question that has been eating at me and I need help

查看:77
本文介绍了您好我有一个delphi问题,一直在吃我,我需要帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个delphi项目,我需要帮助,如编程项目的历史好吧所以它是这样的,我的代码在搜索系统上充实,基本上如果你搜索一个空白的Tedit它会给你一个错误,现在我遇到了一个障碍,因为如果搜索到的项目不存在,我希望它产生一个新的错误......这就是我吃的代码。

"This is a delphi project that I need help with as in History of programming project" ok so it goes like this, I have my code fleshed out on the search system where basically if you search a blank Tedit it will give you an error, now I have hit a road block as I want it to produce a new error if the item searched doesnt exist... this is the code that is eating at me.

procedure TForm1.BtnSearchClick(Sender: TObject);
var
sStudent :String;
begin
    sStudent:=CbSearch.Text;
 if sStudent = ''
then
begin
    Application.MessageBox('No data has been inputed. Please Input a name to search', 'Error no information to search', 0);
end
else
begin
    RDisp.Lines.LoadFromFile('Students\' + sStudent + '.zip');
end;
end;





我知道在Rdisp.Lines下面我需要提供另一个条件声明,但我不知道如何去做...请帮助



我尝试过:



我尝试添加一个if语句,但是一旦它崩溃我的程序就摆脱了它...我知道我需要一个if sStudent =''等,但我没有一个线索是什么...



I know that below the "Rdisp.Lines" I need to provide another conditional if statement but I dont know how to go about it... Please help

What I have tried:

I have tried adding an if statement but I got rid of that as soon as it crashed my program... I know I need an "if sStudent='' "etc, but I dont have a clue what to do it on...

推荐答案

听起来你正在寻找 FileExists 功能 [ ^ ]:

It sounds like you're looking for the FileExists function[^]:
if sStudent = ''
then
begin
    Application.MessageBox('No data has been inputed. Please Input a name to search', 'Error no information to search', 0);
end
else if Not FileExists('Students\' + sStudent + '.zip')
then
begin
    Application.MessageBox('Student file not found.', 'Error file not found', 0);
end
else
begin
    RDisp.Lines.LoadFromFile('Students\' + sStudent + '.zip');
end;



然而,目前尚不清楚 LoadFromFile 方法 [ ^ ]支持读取Zip文件。我希望它只支持文本文件。


However, it's not clear whether the LoadFromFile method[^] supports reading Zip files. I would expect it to only support text files.


这篇关于您好我有一个delphi问题,一直在吃我,我需要帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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