Click here to Skip to main content
12,398,816 members (59,150 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: Delphi
How Can I Add Data(String type or integer and ...) To 'TStringList' From a 'TextFile'and then Count the same Data(this=5, or=3 ,123=12 for example) at last show into the 'ListBox' or 'TextBox' something like that,Please help me anyone who knows Delphi well.
Posted 5-Feb-13 19:36pm

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

To add data, you'll do something like:
SLst := TStringList.Create;
//To add string to a TStringList:
SLst.Add('This is a string');
//or
SLst.Add(VariableName);
 
//To add integer
SLst.Add(IntToStr(55));
//or
SLst.Add(IntToStr(VariableName));
you'll define SLst by:
var
  SLst: TStringList;

And if you want to load it from a textfile:
SLst.LoadFromFile('C:\myfile.txt');
And what do you mean by count the same data? You mean to count how much lines there are in the File? If yes, then:
Count := SLst.Count;

But if you want to show the data in a Memo, then do the following instead of all the above code:
Memo1.Lines.LoadFromFile('C:\myfile.txt');
Count := Memo1.Lines.Count;

I hope my answer helped.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160721.1 | Last Updated 20 Dec 2015
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100