
April 29th, 2004, 03:58 PM
|
 |
Banned ;)
|
|
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
|
|
Another way is to use Pascal's set operator to see if a character is within a set of characters or not. Incidentally, you can refer to a single character in a string by its index, instead of using Copy.
Code:
procedure TForm1.Button1Click(Sender: TObject);
var
sIn : string;
ch : char;
begin
sIn := Edit1.Text;
ch := upcase(sIn[1]);
if (ch in ['A', 'E', 'I', 'O', 'U']) then
ShowMessage(sIn + ' starts with vowel')
else
ShowMessage(sIn + ' starts with consonant');
end;
__________________
Up the Irons
What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
"Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
Down with Sharon Osbourne
|