Solved

text file

Posted on 2003-11-04
3
148 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
  • 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

757 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now