Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Load Random Image and Text OnCreate

Status
Not open for further replies.

Ante0

Programmer
Apr 19, 2007
98
SE
Hi, I just made this code, but it doesn't really work ok.
Code:
Memo2.Lines.LoadFromFile(ExtractFilePath(ParamStr(0))+'names.txt');
MonName.Caption := Memo2.Lines.Strings[Random(75)];
FileListBox1.Directory := ExtractFilePath(ParamStr(0))+'\pictures\mobs\';
ListBox1.Items := FileListBox1.Items;
MonPic.Picture.LoadFromFile(ListBox1.Items.Strings[Random(5)]);
First it loads a random line from the text file names.txt, then load a random picture from the dir 'C:\Programs\picture\mobs\', but, before I added the load picture code, the random line load worked ok. Now when it loads both picture and text, it only chooses random letters in a line. if it's supposed to choose between 'Adam' and 'Eve', it might only take 'am' or 've'.
Could anyone look into this and see what I might've done wrong? Thanks /Ante
 
Just a little brain was all that I needed... lol
By replacing the memo with a listbox it works alright :)
Code:
Memo2.Lines.LoadFromFile(ExtractFilePath(ParamStr(0))+'names.txt');
MonName.Caption := Memo2.Lines.Strings[Random(75)];
with
Code:
ListBox2.Items.LoadFromFile(ExtractFilePath(ParamStr(0))+'names.txt');
MonName.Caption := ListBox2.Items.Strings[Random(75)];

Sorry for this post, guess I'm just too tired for this...
And, how and if, where can you Edit your posts/threads?
 
For editing a post or thread, I have never seen or heard of a way to do it here.
Unless you are a forum admin. =P

~
Give a man some fire, he will be warm for a day, Set a man on fire, he will be warm for the rest of his life.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top