改了还是又问题额~~还是说我VARCHAR的问题~~·
下面是我的代码~~好像有点长~~不过毕业设计急~~所以麻烦大家了~~
Private Sub Form_Load()
LSH_T = CInt(LSH_T)
PSH_T = CInt(PSH_T)
HSH_T = CInt(HSH_T)
SA1_T = CInt(SA1_T)
SA2_T = CInt(SA2_T)
SA1_LQ = CInt(SA1_LQ)
SA1_RQ = CInt(SA1_RQ)
SA2_LQ = CInt(SA2_LQ)
SA2_RQ = CInt(SA2_RQ)
sql = "select * from ls"
Adodc1.RecordSource = sql
Set DataGrid1.DataSource = Adodc1
DataGrid1.Caption = ""
Combo1.AddItem "LSH_T"
'在下拉条中添加10个选项名
Combo1.AddItem "PSH_T"
Combo1.AddItem "HSH_T"
Combo1.AddItem "SA1_T"
Combo1.AddItem "SA2_T"
Combo1.AddItem "SA1_LQ"
Combo1.AddItem "SA1_RQ"
Combo1.AddItem "SA2_LQ"
Combo1.AddItem "SA2_RQ"
Combo2.AddItem "最大值"
'
Combo2.AddItem "最小值"
Combo2.AddItem "平均值"
Combo2.AddItem "总和"
End Sub
Private Sub Command2_Click()
If Combo2.Text = "平均值" Then
sql = "select avg(LSH_T) as LSH_T,avg(PSH_T) as PSH_T,avg(HSH_T) as HSH_T,avg(SA1_T) as SA1_T,avg(SA2_T) as SA2_T,avg(SA1_LQ) as SA1_LQ,avg(SA1_RQ) as SA1_RQ,avg(SA2_LQ) as SA2_LQ,avg(SA2_RQ) as SA2_RQ from ls"
Adodc1.RecordSource = sql
Set DataGrid1.DataSource = Adodc1
Adodc1.Refresh
DataGrid1.Caption = "平均值"
End If
If Combo2.Text = "总和" Then
sql = "select sum(LSH_T) as LSH_T,sum(PSH_T) as PSH_T,sum(HSH_T) as HSH_T,sum(SA1_T) as SA1_T,sum(SA2_T) as SA2_T,sum(SA1_LQ) as SA1_LQ,sum(SA1_RQ) as SA1_RQ,sum(SA2_LQ) as SA2_LQ,sum(SA2_RQ) as SA2_RQ from ls"
Adodc1.RecordSource = sql
Set DataGrid1.DataSource = Adodc1
Adodc1.Refresh
DataGrid1.Caption = "总和"
End If
End Sub