Dim sna(10) As String, sno(10) As String
Dim CHI(10) As Single, ENG(10) As Single, MAT(10) As Single
Dim TOT(10) As Single, AVE(10) As Single, GD(10) As Integer
Dim K As Integer
Private Sub Command1_Click()
K = K + 1
CHI(K) = Val(Text3)
ENG(K) = Val(Text4)
MAT(K) = Val(Text5)
sna(K) = Val(Text1)
sno(K) = Val(Text2)
Text1 = " "
Text2 = " "
Text3 = " "
Text4 = " "
Text5 = " "
End Sub
Private Sub Command2_Click()
For i = 1 To K
TOT(i) = CHI(i) + ENG(i) + MAT(i)
tave = 100 * TOT(i) / 3 + 0.5
AVE(i) = Int(tave) / 100
Next i
ngd = 1
For i = 1 To K
GD(i) = 1
Next
For i = 1 To K - 1
For j = 1 To K
p = GD(i)
q = GD(j)
If TOT(p) < TOT(q) Then
XX = GD(j)
GD(j) = GD(i)
GD(i) = XX
Else
If TOT(p) = TOT(q) Then
If CHI(p) < CHI(q) Then
XX = GD(j)
GD(j) = GD(i)
GD(i) = XX
End If
End If
End If
Next
p = GD(i)
kgd(p) = ngd
ngd = ngd + 1
Next
p = GD(K)
kgd(p) = ngd
Form1.Hide
Form2.Show
Form2.Print Tab(2); "學 號"; Tab(10); "姓 名" _
; Tab(18); "國 文"; Tab(24); "英 文"; Tab(30); "數 學" _
; Tab(36); "總分"; Tab(42); "平均"; Tab(48); "排 名"
Form2.Print "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
For i = 1 To K
Form2.Print Tab(2); sna(i); Tab(10); sno(i) _
; Tab(18); CHI(i); Tab(24); ENG(i); Tab(30); MAT(i) _
; Tab(36); TOT(i); Tab(42); AVE(i); Tab(48); GD(i)
Next
End Sub
Private Sub Form_Activate()
K = 1
End Sub
我都打完了就是不知道錯在那裡
我每次要執行時,都說沒有定義sun或Function......這個要怎麼搞定啊> <
每次都執行都是total(i)和kgd(p)有問題...這個我明天就要用了,拜託各位大哥幫幫我
2005-06-26 17:19:28 · 2 個解答 · 發問者 阿德. 1 in 電腦與網際網路 ➔ 程式設計
請問一下kgd和total宣告在哪呢??
沒有宣告的話,當然找不到呀。
變數可以不用宣告就拿來用(但這是不好的習慣喔)
可是陣列就一定要宣告才能用。
2005-06-27 03:16:32 補充:
陣列的宣告和變數一樣,只不過名稱,要用dim name(n) as 形態來宣告
在最前面多加這一行吧
Dim kgd(10) As Integer
2005-06-27 11:30:20 補充:
真的嗎??我copy你的程式碼後,只要加上kgd的宣告就可以了呢…
但是,排版有問題喔。
你要確定有第二個表單且name是form2喔。
2005-06-26 17:40:18 · answer #1 · answered by 上官 5 · 0⤊ 0⤋
我忘了怎麼宣告....所以才要請各位大哥幫個忙> <
最好是幫我打一下解答> <謝謝
2005-06-27 07:46:21 補充:
在問個問題,為什麼我沒辦法在第2個FORM2裡送出來我打的答案
2005-06-27 20:20:25 補充:
我搞定了,謝謝大哥你的幫忙
2005-06-26 17:42:43 · answer #2 · answered by 阿德. 1 · 0⤊ 0⤋