关于VB编程(急)
代码如下:
private Sub Command1_Click()
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) = (b - p) - a * c / (b - p)
VSFlexGrid1.TextMatrix(5, i) = (a - p) - b * c / (a - p)
VSFlexGrid1.TextMatrix(6, i) = (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
end sub
Private Sub Form_Load()
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 "Y型连接"
Combo1.AddItem "△型连接"
Combo2.AddItem "a连y、b连z、c连x"
Combo2.AddItem "a连z、b连x、c连y"
End Sub
问题1:我运行调试的时候在 VSFlexGrid1.TextMatrix(4, i) = (b - p) - a * c / (b - p)这行显示黄色,提示是“溢出”
问题2:在表里输入数字时再点一下其它地方的表格,列方向的 “AB”“AC”“BC”等都不显示了。(刚开始运行的时候是有显示的)
说详细点
谢谢
参考答案:我运行调试的时候在 VSFlexGrid1.TextMatrix(4, i) = (b - p) - a * c / (b - p)这行显示黄色,提示是“溢出”,我测试时是(b - p)=0