English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
所有分類

成績查詢程式
須要設密碼
密碼檢查( 三次錯誤)
如果錯誤=>程式結束
成績查詢=>(至少10人 要有三科成績)
成績=> (需要計算三科平均)

2005-11-28 16:18:58 · 2 個解答 · 發問者 jasan 1 in 電腦與網際網路 程式設計

2 個解答

Option Explicit

Private Type MyScore
Chinese As Byte
English As Byte
Math As Byte
Average As Single
End Type
Private Sub Form_Activate()
Dim sc() As MyScore, i As Integer, n As Integer
Dim mystr As String, tmp As Variant, total As Integer

n = 0
Do
n = n + 1
ReDim Preserve sc(n) As MyScore
Randomize
mystr = InputBox("輸入第 " & n & " 位之成績,輸入格式:國文,英文,數學;" _
& "範例:100,90,80;輸入 -1 表示輸入結束" _
, , Fix(Rnd * 100) + 1 & "," & Fix(Rnd * 100) + 1 & "," & Fix(Rnd * 100) + 1)
If Val(mystr) = -1 Then n = n - 1: Exit Do
tmp = Split(mystr, ",")
With sc(n)
.Chinese = Val(tmp(0))
.English = Val(tmp(1))
.Math = Val(tmp(2))
End With
total = 0
For i = 0 To 2
total = total + Val(tmp(i))
Next
sc(n).Average = Int((total / 3) * 100 + 0.5) / 100
Loop
Print "編號", "國文", "英文", "數學", "平均": Print
For i = 1 To n
Print i, sc(i).Chinese, sc(i).English, sc(i).Math, sc(i).Average
Next

End Sub

Private Sub Form_Load()
'預設密碼 123456
Const MyPassWord = "123456"
Dim i As Integer
For i = 1 To 3
If InputBox("請輸入通關密碼", "Visual Basic6.0") = MyPassWord Then Exit For
Next
If i = 4 Then MsgBox "錯誤三次,系統自爆", vbCritical, "Visual Basic6.0": End
End Sub

2005-11-28 18:53:09 · answer #1 · answered by ? 6 · 0 0

我是過了!!但是"平均"好像沒有的樣子,不過已經可以了!!謝謝你唷!!

2005-11-30 12:22:08 · answer #2 · answered by jasan 1 · 0 0

fedest.com, questions and answers