Einzelnen Beitrag anzeigen

Daniel B
(Gast)

n/a Beiträge
 
#1

Brauche Nachhilfe in Case

  Alt 29. Jun 2002, 12:53
Hi,

ich habe 3-4 solcher abfragen/änderungen. Sowas lässt sich doch bestimmt mit case einfacher lösen. Ich verstehe es einfach nicht. Vielleicht kann mir jemand helfen.
Vielen Dank.


Code:
  if MainFormMC2004.ComPort.Port = 'COM1' then
  begin
    ComboBoxPort.ItemIndex:=0;
  end
  else if MainFormMC2004.ComPort.Port = 'COM2' then
  begin
    ComboBoxPort.ItemIndex:=1;
  end
  else if MainFormMC2004.ComPort.Port = 'COM3' then
  begin
    ComboBoxPort.ItemIndex:=2;
  end
  else if MainFormMC2004.ComPort.Port = 'COM4' then
  begin
    ComboBoxPort.ItemIndex:=3;
  end
  else if MainFormMC2004.ComPort.Port = 'COM5' then
  begin
    ComboBoxPort.ItemIndex:=4;
  end
  else if MainFormMC2004.ComPort.Port = 'COM6' then
  begin
    ComboBoxPort.ItemIndex:=5;
  end
  else if MainFormMC2004.ComPort.Port = 'COM7' then
  begin
    ComboBoxPort.ItemIndex:=6;
  end
  else if MainFormMC2004.ComPort.Port = 'COM8' then
  begin
    ComboBoxPort.ItemIndex:=7;
  end;
  Mit Zitat antworten Zitat