Can anyone provide me with an example how to create a program using Delphi that randomizes and shows 2 words out of 78 with a click of a button? The words are:

Afghanistan
Albania
Argentina
Australia
Ausria
Blegium
Bhutan
Bolivia
Brazil
Bulgaria
Canada
Chile
Colombia
Communist_China
Costa_Rica
Cuba
Czechoslovakia
Dennmark
Dominican_Republic
Equador
El_Salvador
Estonia
Ethiopia
France
Finland
Germany
Greece
Guangxi_Clique
Guatemala
Haiti
Honduras
Hungary
Iraq
Ireland
Italy
Japan
Latvia
Liberia
Lithuania
Luxemburg
Manchukuo
Mexico
Mongolia
Nepal
Nationalist_China
Netherlands
New_Zealand
Nicaragua
Norway
Oman
Panama
Paraguay
Persia
Peru
Philippines
Poland
Portugal
Republican_Spain
Romania
Saudi_Arabia
Shanxi
Siam
Sinkiang
South_Africa
Soviet_Union
Sweden
Switzerland
Tannu_Tuva
Tibet
Turkey
United_Kingdom
Uruguay
USA
Venezuela
Xibei_San_Ma
Yemen
Yunnan
Yugoslavia

Recommended Answers

All 3 Replies

If you load your strings into a tstringlist, then you can use the random function to select a random line.

I am terribly sorry, but I have no idea how to load my strings into a stringlist. Could you be a little more detailed?

var
  sl: TStringList;
begin
  sl := TStringList.Create;
  sl.LoadFromFile(yourtextfilehere.txt);
  ShowMessage(sl[Random(sl.Count)]);
  sl.Free;
end;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.