任何人都可以帮我这个delphi代码? [英] Can anyone help me with this delphi code?

查看:85
本文介绍了任何人都可以帮我这个delphi代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿大家!,这里的主要问题一直让我烦恼,原因是我的代码工作了,现在已停止了,这是相当自发的,程序正常,因为数据存储在剪贴板上,但它不写文本文件



程序TForm1.BtnSaveClick(发件人:TObject); 
var
F,E:TextFile;
sName,sSur,sEmail,sTelKid,sMom,sDad,sTelMom,sTelDad,sLs,sSchool,sSchoolTel,sSchoolEmail: String ;
开始
sName:= EdtName。 text ;
sSur:= EdtSur。 text ;
sEmail:= EdtEmail。 text ;
sTelKid:= EdtTelKid。 text ;
sTelMom:= EdtTelMom。 text ;
sTelDad:= EdtTelDad。 text ;
sSchool:= EdtSchool。 Text ;
sSchoolTel:= EdtSchoolTel。 Text ;
sSchoolEmail:= EdtSchoolEmail。 Text ;
sMom:= EdtMum。文字;
sDad:= EdtDad。 Text ;
sLs:= ClevelS。 Text ;
AssignFile(E,' Config\list.txt');
追加(E);
Writeln(E,sName + ' ' + sSur);
关闭文件(E);
CBSearch.Items.LoadFromFile(' Config\list.txt');
CBSearch.Items.SaveToFile(' Config\list.txt');
AssignFile(F,' Students\'+ sName +' ' + sSur +' .txt ' );
重写(F);
WriteLn(F,'
' + sSchool);
WriteLn(F);
WriteLn(F,'
Correo Electronico:' + sSchoolEmail);
WriteLn(F);
WriteLn(F,'
Numero de telefono:' + sSchoolTel);
WriteLn(F);
WriteLn(F,'
_____________________________________________________________ ' );
WriteLn(F,'
_____________________________________________________________ ' );
WriteLn(F);
WriteLn(F,'
NOMBRE:' + sName);
WriteLn(F);
WriteLn(F,'
APPELIDOS:' + sSur);
WriteLn(F);
WriteLn(F,'
EMAIL:' + sEmail);
WriteLn(F);
WriteLn(F,'
TELEFONO DE ESTUDIANTE:' + sTelKid);
WriteLn(F);
WriteLn(F,'
TELEFONO DE ' + sMom +'' + sTelMom);
WriteLn(F);
WriteLn(F,'
TELEFONO DE ' + sDad +'' + sTelDad);
WriteLn(F);
WriteLn(F,'
NIVEL DE LENGUAGE:' + sLs);
关闭文件(F);
imgStudent.Picture.SaveToFile('
Data \ ' + sName +' ' + sSur +' .jpg ' < span class =code-string>);
结束;





我的尝试:



它正在工作然后停止了。我不知道还能说什么...

解决方案

引用:

原因是我的代码工作,现在它停止了,这是相当自发的,程序工作,因为数据存储在剪贴板上,但它不写文本文件

如果它正在工作和停止,它是链接对数据,使用调试器来查看发生了什么。



你应该学会尽快使用调试器。而不是猜测你的代码在做什么,现在是时候看到你的代码执行并确保它完成你期望的。



调试器允许你跟踪执行逐行检查变量,你会看到它有一个停止做你期望的点。

调试器 - 维基百科,免费的百科全书 [ ^ ]

掌握Visual Studio 2010中的调试 - A初学者指南 [ ^ ]



调试器在这里向您展示您的代码正在做什么,您的任务是与它应该做什么进行比较。 />
当代码不做ex的时候你接近了一个bug。


鉴于它正在运行,现在它停止了。我认为没有改变代码。



这似乎是一个转发,因为我甚至认识到代码。你上次有什么帮助?



我很确定你被告知不写文件并不是对问题的完美描述。



建议:



您是否收到任何错误消息/异常?您尝试归档的位置是否存在?您的应用程序是否有权在任何地方写入?



如果代码没有改变,您可能应该认为您的计算机上有外部因素这会影响你的问题。鉴于此,我们无法真正帮助那些因为我们看不到你的电脑。



但是很可能重复你之前给出的答案。< br $>


CBSearch.Items.SaveToFile('Config\list.txt');



那个Config目录可能不存在。除此之外,没有什么可说的。



http://www.codeproject.com/Questions/1125178/Delphi-problems-with-text-files [ ^ ]


Hey everyone!, Major question here that has been annoying me, Reason being is my code worked and now its stopped, It was rather spontaneous, The program works, as in the data is stored on the clipboard, But it doesnt write the text files

procedure TForm1.BtnSaveClick(Sender: TObject);
var
  F, E: TextFile;
  sName, sSur, sEmail, sTelKid, sMom, sDad, sTelMom, sTelDad, sLs, sSchool, sSchoolTel, sSchoolEmail: String;
begin
  sName:=EdtName.text;
  sSur:=EdtSur.text;
  sEmail:=EdtEmail.text;
  sTelKid:=EdtTelKid.text;
  sTelMom:=EdtTelMom.text;
  sTelDad:=EdtTelDad.text;
  sSchool:=EdtSchool.Text;
  sSchoolTel:=EdtSchoolTel.Text;
  sSchoolEmail:=EdtSchoolEmail.Text;
  sMom:=EdtMum.Text;
  sDad:=EdtDad.Text;
  sLs:=ClevelS.Text;
  AssignFile(E, 'Config\list.txt');
  append(E);
  Writeln(E,sName + ' ' + sSur);
  CloseFile(E);
  CBSearch.Items.LoadFromFile('Config\list.txt');
  CBSearch.Items.SaveToFile('Config\list.txt');
  AssignFile(F, 'Students\' +sName+ ' ' +sSur+ '.txt');
  Rewrite(F);
  WriteLn(F, '  ' +sSchool);
  WriteLn(F);
  WriteLn(F, '  Correo Electronico: ' +sSchoolEmail);
  WriteLn(F);
  WriteLn(F, '  Numero de telefono: ' +sSchoolTel);
  WriteLn(F);
  WriteLn(F, '_____________________________________________________________');
  WriteLn(F, '_____________________________________________________________');
  WriteLn(F);
  WriteLn(F, '  NOMBRE: ' +sName);
  WriteLn(F);
  WriteLn(F, '  APPELIDOS: ' +sSur);
  WriteLn(F);
  WriteLn(F, '  EMAIL: ' +sEmail);
  WriteLn(F);
  WriteLn(F, '  TELEFONO DE ESTUDIANTE: ' +sTelKid);
  WriteLn(F);
  WriteLn(F, '  TELEFONO DE '+sMom+' : ' +sTelMom);
  WriteLn(F);
  WriteLn(F, '  TELEFONO DE '+sDad+' : ' +sTelDad);
  WriteLn(F);
  WriteLn(F, '  NIVEL DE LENGUAGE: ' +sLs);
  CloseFile(F);
  imgStudent.Picture.SaveToFile('Data\'+sName+' '+sSur+'.jpg');
end; 



What I have tried:

It was working then it stopped. I dont know what else to say...

解决方案

Quote:

Reason being is my code worked and now its stopped, It was rather spontaneous, The program works, as in the data is stored on the clipboard, But it doesnt write the text files

If it was working and stopped, it is linked to the data, use the debugger to see what is going on.

You should learn to use the debugger as soon as possible. Rather than guessing what your code is doing, It is time to see your code executing and ensuring that it does what you expect.

The debugger allow you to follow the execution line by line, inspect variables and you will see that there is a point where it stop doing what you expect.
Debugger - Wikipedia, the free encyclopedia[^]
Mastering Debugging in Visual Studio 2010 - A Beginner's Guide[^]

The debugger is here to show you what your code is doing and your task is to compare with what it should do.
When the code don't do what is expected, you are close to a bug.


Given that it was working and now it stopped. I take that as nothing was changed to the code.

This seems like a repost as i even recognize the code. What help did you get last time?

I'm pretty sure you got told "doesn't write to file" isn't exactly a great description of the problem.

Suggestions:

Are you getting any error messages/exceptions? Does the location you are trying to right to file exist? Does your application have the rights to write to wherever it is attempting to?

If the code didn't change you probably should think that there are external factors on your computer that affect your issue. Given that, we can't really help with those as we can't see your computer.

But to more than likely repeat the answer you were given before.

CBSearch.Items.SaveToFile('Config\list.txt');

That Config directory probably doesn't exist. Other than that, there isn't much else to say.

http://www.codeproject.com/Questions/1125178/Delphi-problems-with-text-files[^]


这篇关于任何人都可以帮我这个delphi代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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