代码如下:
If combo1.Text = "△型连接" Then
Combo2.Visible = True
Else: Combo2.Visible = False
End If
End Sub
For i = 1 To VSFlexGrid1.Cols - 1
a = Val(VSFlexGrid1.TextMatrix(1, i))
b = Val(VSFlexGrid1.TextMatrix(2, i))
c = Val(VSFlexGrid1.TextMatrix(3, i))
VSFlexGrid1.TextMatrix(4, i) = (a + b - c) / 2
VSFlexGrid1.TextMatrix(5, i) = (a + c - b) / 2
VSFlexGrid1.TextMatrix(6, i) = (b + c - a) / 2
Next i
For i = 1 To VSFlexGrid1.Rows - 1
For j = 0 To VSFlexGrid1.Cols - 1
If Val(VSFlexGrid1.TextMatrix(i, j)) = 0 Then VSFlexGrid1.TextMatrix(i, j) = ""
Next j
Next i
End If
If combo1.Text = "△型连接" And Combo2.Text = "a连y、b连z、c连x" Then
Dim p As Single
For i = 1 To VSFlexGrid1.Cols - 1
a = Val(VSFlexGrid1.TextMatrix(1, i))
b = Val(VSFlexGrid1.TextMatrix(2, i))
c = Val(VSFlexGrid1.TextMatrix(3, i))
p = (a + b + c) / 3
VSFlexGrid1.TextMatrix(4, i) = CStr((b - p) - a * c / (b - p))
VSFlexGrid1.TextMatrix(5, i) = CStr((a - p) - b * c / (a - p))
VSFlexGrid1.TextMatrix(6, i) = CStr((c - p) - a * b / (c - p))
Next i
For i = 1 To VSFlexGrid1.Rows - 1
For j = 0 To VSFlexGrid1.Cols - 1
If Val(VSFlexGrid1.TextMatrix(i, j)) = 0 Then VSFlexGrid1.TextMatrix(i, j) = ""
Next j
Next i
End If
VSFlexGrid1.TextMatrix(0, 0) = "档位"
VSFlexGrid1.TextMatrix(0, 1) = "Ⅰ"
VSFlexGrid1.TextMatrix(0, 2) = "Ⅱ"
VSFlexGrid1.TextMatrix(0, 3) = "Ⅲ"
VSFlexGrid1.TextMatrix(0, 4) = "Ⅳ"
VSFlexGrid1.TextMatrix(0, 5) = "Ⅴ"
VSFlexGrid1.TextMatrix(0, 5) = "Ⅵ"
VSFlexGrid1.TextMatrix(0, 6) = "Ⅶ"
VSFlexGrid1.TextMatrix(0, 7) = "Ⅷ"
VSFlexGrid1.TextMatrix(0, 8) = "Ⅸ"
VSFlexGrid1.TextMatrix(1, 0) = "AB"
VSFlexGrid1.TextMatrix(2, 0) = "AC"
VSFlexGrid1.TextMatrix(3, 0) = "BC"
VSFlexGrid1.TextMatrix(4, 0) = "A"
VSFlexGrid1.TextMatrix(5, 0) = "B"
VSFlexGrid1.TextMatrix(6, 0) = "C"
combo1.AddItem "△型连接"
Combo2.AddItem "a连y、b连z、c连x"
Combo2.AddItem "a连z、b连x、c连y"
End Sub
Private Sub VSFlexGrid1_BeforeEdit(ByVal Row As Long, ByVal Col As Long, Cancel As Boolean)
'限定不可编辑列,如有5列
If Row = 4 Then Cancel = True
If Row = 5 Then Cancel = True
If Row = 6 Then Cancel = True
End Sub
问题2:在表里输入数字后点“Command1”运行时,列方向的 “AB”“AC”“BC”等都不显示了。(没点“Command1”前是会显示的)