这是个很简单的程序,但是小弟学艺不精,怎么运行都有问题,那个界面怎么显示都不全,但是又不知道怎么回事,搞的满头大汗。是用vb编的,小弟快急死了,各位帮忙啊。
一下是源代码和源文件。
Dim GC(20) As Single, GX(20) As Single
Dim AMF(20, 2) As Single, AM(20, 2) As Single
Dim P(21) As Single, AK(21, 21) As Single, XG(20) As Single
Dim NJ As Integer, NNE As Integer
Dim IL As Integer, IR As Integer
Dim Title As String
Private Sub Form_Load()
B1.TextMatrix(0, 0) = "单元号"
B1.TextMatrix(0, 1) = "单元长度"
B1.TextMatrix(0, 2) = "抗弯刚度"
B1.TextMatrix(0, 3) = "左端固端弯矩"
B1.TextMatrix(0, 4) = "右端固端弯矩"
B2.TextMatrix(0, 0) = "结点号"
B2.TextMatrix(0, 1) = "结点角位移"
B3.TextMatrix(0, 0) = "单元号"
B3.TextMatrix(0, 1) = "左端弯矩"
B3.TextMatrix(0, 2) = "右端弯矩"
B1.RowHeight = 400
B1.ColWidth(0) = 800: B1.ColWidth(1) = 1500: B1.ColWidth(2) = 1500
B1.ColWidth(3) = 1500: B1.ColWidth(4) = 1500:
B2.RowHeight = 400
B2.ColWidth(0) = 800: B2.ColWidth(1) = 1500
B3.RowHeight = 400
B3.ColWidth(0) = 800: B3.ColWidth(1) = 1500: B3.ColWidth(2) = 1500
End Sub
Private Sub Command1_Click()
B1.Rows = Val(T2.Text)
B1.Clos = 5
For i = 1 To Val(T2.Text) - 1
B1.TextMarix(i, 0) = i
Next i
B2.Rows = Val(T2.Text) + 1
B2.Clos = 2
For i = 1 To Val(T2.Text)
B2.TextMarix(i, 0) = i
Next i
B3.Rows = Val(T2.Text)
B3.Clos = 3
For i = 1 To Val(T2.Text) - 1
B3.TextMarix(i, 0) = i
Next i
End Sub
Private Sub Command2_Click()
NJ = Val(T2)
IL = Val(T3)
IR = Val(T4)
NNE = NJ - 1
For i = 1 To NNE
GC(i) = Val(B1.TextMatrix(i, 1)): GX(i) = Val(B1.TextMatrix(i, 2))
AMF(i, 1) = Val(B1.TextMatrix(i, 3)): AMF(i, 2) = Val(B1.TextMatrix(i, 4))
Next i
For i = 1 To NNE
XG(i) = GX(i) / GC(i)
Next i
P(1) = -AMF(1, 1)
P(NJ) = -AMF(NNE, 2)
For i = 2 To NNE
P(i) = -AMF(i - 1, 2) - AMF(i, 1)
Next i
For i = 1 To NJ
For j = 1 To NJ
AK(i, j) = 0
Next j
Next i
AK(1, 1) = 4 * XG(1)
AK(NJ, NJ) = 4 * XG(NNE)
For j = 2 To NNE
AK(j, j) = 4 * (XG(j - 1) + XG(j))
Next j
For j = 2 To NJ
AK(j, j - 1) = 2 * XG(j - 1)
AK(j - 1, j) = 2 * XG(j - 1)
Next j
If IL <> 0 Then
AK(1, 1) = 1
AK(1, 2) = 0
AK(2, 1) = 0
P(1) = 0
End If
If IR <> 0 Then
AK(NJ, NJ) = 1
AK(NNE, NJ) = 0
AK(NJ, NNE) = 0
P(NJ) = 0
End If
For k = 1 To NNE
For i = k + 1 To NJ
C = AK(i, k) / AK(k, k)
P(i) = P(i) - C * P(k)
For j = 1 To NJ
AK(i, j) = AK(i, j) - C * AK(k, j)
Next j
Next i
Next k
P(NJ) = (NJ) / AK(NJ, NJ)
For i = NNE To 1 Step -1
s = 0
For j = i + 1 To NJ
s = s + AK(i, j) * P(j)
Next j
P(i) = (P(i) - s) / AK(i, i)
Next i
For i = 1 To NJ
B2.TextMatrix(i, 0) = i
B2.TextMatrix(i, 1) = P(i)
Next i
For i = 1 To NNE
AM(i, 1) = 4 * XG(i) * P(i) + 2 * XG(i) * P(i + 1) + AMF(i, 1)
AM(i, 2) = 2 * XG(i) * P(i) + 4 * XG(i) * P(i + 1) + AMF(i, 2)
Next i
For i = 1 To NNE
B3.TextMatrix(i, 0) = i
B3.TextMatrix(i, 1) = AM(i, 1)
B3.TextMatrix(i, 2) = AM(i, 2)
Next i
End Sub
Private Sub Command3_Click()
Open App.Path + "\ cbsap.out" For Output As #1
Print #1, "题 目:"; T1.Text
Print #1, "结点数 左端支承信息 右端支承信息“"
Print #1, Val(T2.Text), Val(T3.Text), Val(T4.Text)
Print #1, "单元号 长度 抗弯刚度 左端固端弯矩 右端固端弯矩”"
For i = 1 To Val(T2.Text) - 1
Print #1, i, Val(B1.TextMatrix(i, 1)), Val(B1.TextMatrix(i, 2))
Val (B1.TextMatrix(i, 3)), Val(B1.TextMatrix(i, 4))
Next i
Print #1, "结点号 结点位移"
For i = 1 To Val(T2.Text)
Print #1, i, Val(B2.TextMatrix(i, 1))
Next i
Print #1, "单元号 左端弯矩 右端弯矩"
For i = 1 To Val(T2.Text) - 1
Print #1, i, Val(B3.TextMatrix(i, 1)), Val(B3.TextMatrix(i, 2))
Next i
Close
End
Private Sub Text3_Change()
End Sub