📄 unit21.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit21.h"
#include "IsNumber.h"
#include "Unit20.h"
#include "stdio.h"
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TFormInData *FormInData;
//---------------------------------------------------------------------------
__fastcall TFormInData::TFormInData(TComponent* Owner)
: TForm(Owner)
{
selectrow = -1;
selectcol = -1;
}
//---------------------------------------------------------------------------
void __fastcall TFormInData::btnCancelClick(TObject *Sender)
{
bOK=false;
Close();
}
//---------------------------------------------------------------------------
void __fastcall TFormInData::btnOKClick(TObject *Sender)
{
int i;
float t, val;
int num;
if(StringGrid1->RowCount > 1)
{
if(StringGrid1->Cells[1][1] != "")
{
val = 0.0;
num = 0;
for(i = 1; i < StringGrid1->RowCount; i++)
{
if(StringGrid1->Cells[1][i] != "")
{
t = StrToFloat(StringGrid1->Cells[1][i]);
val = val + t;
num++;
}
}
val = val / num;
fRVal = val;
iNum = num;
bOK = true;
Close();
}
}
}
//---------------------------------------------------------------------------
void __fastcall TFormInData::FormShow(TObject *Sender)
{
StringGrid1->RowCount = 2;
StringGrid1->Cells[0][0]="序号";
StringGrid1->Cells[1][0]="吸光度值";
StringGrid1->Cells[1][1]="";
bOK = false;
}
//---------------------------------------------------------------------------
void __fastcall TFormInData::FormCreate(TObject *Sender)
{
StringGrid1->Cells[0][0]="序号";
StringGrid1->Cells[1][0]="吸光度值";
for(int i=1;i<StringGrid1->RowCount;i++)
StringGrid1->Cells[0][i]=IntToStr(i);
}
//---------------------------------------------------------------------------
void __fastcall TFormInData::StringGrid1SelectCell(TObject *Sender,
int ACol, int ARow, bool &CanSelect)
{
selectcol=ACol;
selectrow=ARow;
}
//---------------------------------------------------------------------------
void __fastcall TFormInData::DEL1Click(TObject *Sender)
{
int i;
if(selectrow <= 0 || selectcol <= 0) return;
if(Application->MessageBox("是否删除选中的数据?",
"提示",MB_YESNO|MB_ICONWARNING)==IDNO) return;
for(i = selectrow; i < StringGrid1->RowCount; i++)
{
StringGrid1->Cells[1][i]=StringGrid1->Cells[1][i+1];
StringGrid1->Cells[0][i]=IntToStr(i);
}
if(StringGrid1->RowCount == 2)
{
StringGrid1->Cells[0][StringGrid1->RowCount - 1] = IntToStr(StringGrid1->RowCount - 1);
StringGrid1->Cells[1][StringGrid1->RowCount - 1] = "";
}
else
{
StringGrid1->RowCount = StringGrid1->RowCount - 1;
}
}
//---------------------------------------------------------------------------
void __fastcall TFormInData::btnAcqClick(TObject *Sender)
{
float t;
char gs[80];
t = Form1->tas(1);
t = Form1->pp2*t*Form1->tbb()*100.0;
t = Form1->toa(t);
sprintf(gs, "%1.3f", t);
StringGrid1->Cells[1][StringGrid1->RowCount - 1] = gs;
StringGrid1->RowCount = StringGrid1->RowCount + 1;
StringGrid1->Cells[0][StringGrid1->RowCount - 1] = IntToStr(StringGrid1->RowCount - 1);
StringGrid1->Cells[1][StringGrid1->RowCount - 1] = "";
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -