enf*_*am3 9 delphi combobox tcombobox
我的问题是关于Delphi 7.我需要获取当前选择的ComboBox1值,以便在我的代码中将其用作浮点变量:
t:=t+ComboBox1. // Not sure what to write here...
Run Code Online (Sandbox Code Playgroud)
谢谢!
TLa*_*ama 10
不确定TryStrToFloat是否已经在Delphi 7中,但如果是,我会这样做.
procedure TForm1.ComboBox1Change(Sender: TObject);
var
Value: Double;
begin
if TryStrToFloat(ComboBox1.Text, Value) then
T := T + Value
else
ShowMessage('You''ve entered wrong value ...');
end;
Run Code Online (Sandbox Code Playgroud)
// ItemIndex is the index of the selected item
// If no item is selected, the value of ItemIndex is -1
if (ComboBox1.ItemIndex >= 0) then
begin
t := t + StrToFloat(ComboBox1.Items[ComboBox1.ItemIndex]);
end;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
61566 次 |
| 最近记录: |