VB的程式請教高手
求救啊...VB的程式請教高手
查詢可以改變大小 排序那不行...
不知哪裡寫錯了?
Dim n(50) As String
Dim c(50) As Integer
Dim e(50) As Integer
Private Sub Command1_Click()
w = InputBox("學生數")
For i = 1 To w
n(i) = InputBox("請輸入姓名:", "請輸入姓名")
c(i) = InputBox("請輸入國文成績:", "請輸入成績")
e(i) = InputBox("請輸入英文成績:", "請輸入成績")
Next i
End Sub
Private Sub Command2_Click()
If Option1.Value Then
Font.Size = 12
ElseIf Option2.Value Then
Font.Size = 16
Else
Font.Size = 18
End If
If Option4.Value Then
Font.Italic = False
Font.Bold = False
ElseIf Option5.Value Then
Font.Italic = True
Font.Bold = False
ElseIf Option6.Value Then
Font.Italic = False
Font.Bold = True
Else
Font.Italic = True
Font.Bold = True
End If
a = InputBox("請輸入姓名:", "輸入姓名")
b = ""
d = 0
For i = 1 To 50
If n(i) = a Then
b = n(i)
d = c(i)
f = e(i)
End If
Next i
If b = "" Then
Print "資料錯誤!!"
Else
Cls
Print "姓名: " & b & " 國文成績: " & d & "英文: " & f
End If
End Sub
Private Sub Command3_Click()
If Option1.Value Then
Font.Size = 12
ElseIf Option2.Value Then
Font.Size = 16
Else
Font.Size = 18
End If
If Option4.Value Then
Font.Italic = False
Font.Bold = False
ElseIf Option5.Value Then
Font.Italic = True
Font.Bold = False
ElseIf Option6.Value Then
Font.Italic = False
Font.Bold = True
Else
Font.Italic = True
Font.Bold = True
End If
Dim a As String
Dim b As Integer
Dim h As Integer
FontSize = 14
w = InputBox("學生數")
Cls
For i = w - 1 To 0 Step -1
For j = 0 To i
If c(j) < c(j + 1) Then
a = n(j)
b = c(j)
h = e(j)
n(j) = n(j + 1)
c(j) = c(j + 1)
e(j) = e(j + 1)
n(j + 1) = a
c(j + 1) = b
e(j + 1) = h
End If
Next j
Next i
Cls
For z = 0 To w - 1
Print " 名次: " & z + 1 & " 姓名: " & n(z) & " 成績: " & c(z) & " 英: " & e(z) & " 平均: " & (c(z) + e(z)) / 2
Print
Next z
End Sub
|