Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

This error driving me crazy! "Ordinal Type required"

combobox

  • Please log in to reply
2 replies to this topic

#1 2710

2710

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 110 posts

Posted 12 November 2009 - 06:54 AM

Hi,

I got a combo box where you can select stuff and I coded it with this:


procedure TFrmDatabase.ComboBox1Change(Sender: TObject);
begin

case combobox1.Text of

'GiftAidID': searchbox.Width:= 80;
'Title': searchbox.Width:= 50;
'Initial': searchbox.Width:= 20;
'Surname': searchbox.Width:= 100;
'Address': searchbox.Width:= 500;
'PostCode': searchbox.Width:= 100;
'E-mail': searchbox.Width:= 400;
'DateR': searchbox.Width:= 200;
'AmountRaised': searchbox.Width:= 70;

end;

But the stupid program keeps highlighting the bolded part and says: 'Ordinal Type required'!

Any help appreciated? I have always done case this way, well i pascal anyways.

Thanks
  • 0

#2 WingedPanther73

WingedPanther73

    A spammer's worst nightmare

  • Moderator
  • 17757 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others

Posted 12 November 2009 - 08:37 AM

Case statements require NUMBERS, not strings. Specifically, an ordinal type is an Integer, Word, etc.
  • 0

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/


#3 2710

2710

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 110 posts

Posted 12 November 2009 - 11:00 AM

But in pascal, I was able to use strings...so is that just pascal?

Omg, so I have to give each variable a number and then do it? argh.

EDIT:

Lucky me, I can use the Combobox's 'itemindex' . I would have had to list all everything otherwise >_>
  • 0





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download