Solved

text file

Posted on 2003-11-04
3
155 Views
Last Modified: 2011-09-20
I have a combobox with some names
a button below
i want when i select a name from combo and push the button
to create me in C:\Temp a new empty text file with the name from the combo
ex if the selected name is John Mark create C:\Temp\John Mark.txt
Thanks
0
Comment
Question by:tinti
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 1

Accepted Solution

by:
rvicentiu earned 35 total points
ID: 9679934
it's easy...

procedure TForm1.Button1Click(Sender: TObject);
begin
  with TFileStream.Create('C:\TEMP\'+Combobox1.Items[Combobox1.ItemIndex]+'.txt', fmCreate) do Free;
end;
0
 
LVL 3

Expert Comment

by:ThoseBug
ID: 9680770
procedure TForm1.Button1Click(Sender: TObject);
var
  FileHandle: Integer;
begin
  FileHandle := FileCreate('c:\temp\'+combobox1.text);
  if FileHandle<0 then showmessage('create file error')
end;
0
 
LVL 3

Expert Comment

by:ThoseBug
ID: 9680790
//uupps  add '.txt'

procedure TForm1.Button1Click(Sender: TObject);
var
  FileHandle: Integer;
begin
  FileHandle := FileCreate('c:\temp\'+combobox1.text+'.txt');
  if FileHandle<0 then showmessage('create file error')
end;
end.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question