Jump to content
Sign in to follow this  

Looping </>

Recommended Posts


I'm new to Delphi and to programming in general I have a hard time realizing my idea. Maybe somebody here can help me.. 

I've a list of numbers, I've already imported into Delphi. Now I want to loop thru them and determine if the number is </> than 5. If smaller than 'Micro', if bigger than 'Macro'  should be displayed beside the number. I'm stuck here!

At the end it would be cool to count the total number of Macro and Micro, but I think I'm able to do that. I would really appreciate some help! Thanks! 


Share this post

Link to post
Posted (edited)

You're making it unnecessarily hard for you if you rely on interface elements (like the TMemo) for data storage and processing.


I guess the button "Read data" gets the numbers from the memo and then keeps them in an array or list? If yes, that's good, because it's probably the hardest part. Because if you have your numbers in a list or an array, you can then easily loop over them with a for statement.


If you have some code (especially what is behind your "read data") then we could help with advice tailored to your project, instead of general recommendations.

Edited by Der schöne Günther

Share this post

Link to post

Sorry of course! 

I'm reading the data from a txt.file, because then it will be easier to read already existing new data. At least that's my plan.

I hope that helps to understand.


Share this post

Link to post

You should use the code blocks and insert the code within the forum, posting screen shots of the code wont help


You should think twice before using TMEMO as a list handler 


You can create an object that holds your preferred variables and add the object to a list and use it accordingly 

Share this post

Link to post
Posted (edited)

Hi all...:classic_cool:


You should think twice before using TMEMO as a list handler 





1. create a TStringList as a private variable

2. read the *.txt file into a TStringlist  http://docwiki.embarcadero.com/Libraries/Seattle/en/System.Classes.TStrings.LoadFromFile


3. show the content of the *.txt File in the MEMO

Memo.Text := List.Text


4. iterate through the lines of the List if you want to Work with the data

for I := 0 to List.Count - 1 do
  // your work

5. if you change the data in the list, reload the MEMO

Memo.Text := List.Text


...finish. :classic_cool:


:classic_blink: German names? If you  search the german DP ... https://www.delphipraxis.net

Edited by haentschman

Share this post

Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this