|
論壇說明 |
歡迎您來到『史萊姆論壇』 ^___^ 您目前正以訪客的身份瀏覽本論壇,訪客所擁有的權限將受到限制,您可以瀏覽本論壇大部份的版區與文章,但您將無法參與任何討論或是使用私人訊息與其他會員交流。若您希望擁有完整的使用權限,請註冊成為我們的一份子,註冊的程序十分簡單、快速,而且最重要的是--註冊是完全免費的! 請點擊這裡:『註冊成為我們的一份子!』 |
|
主題工具 | 顯示模式 |
2008-12-06, 08:41 PM | #1 |
註冊會員
|
討論 - VB寫成績問題
Public Class Form1
Inherits System.Windows.Forms.Form Dim Grade(5, 6) As Object Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As _ System.EventArgs) Handles MyBase.Load Grade(1, 1) = "小玫" Grade(1, 2) = 98 '國文常識 Grade(1, 3) = 72 '計算機概論 Grade(1, 4) = 82 '動力學 Grade(1, 5) = 73 '或然率 Grade(1, 6) = 76 '體育 Grade(2, 1) = "小茹" Grade(2, 2) = 89 Grade(2, 3) = 92 Grade(2, 4) = 86 Grade(2, 5) = 93 Grade(2, 6) = 82 Grade(3, 1) = "小君" Grade(3, 2) = 63 Grade(3, 3) = 70 Grade(3, 4) = 60 Grade(3, 5) = 54 Grade(3, 6) = 70 Grade(4, 1) = "小雅" Grade(4, 2) = 72 Grade(4, 3) = 68 Grade(4, 4) = 74 Grade(4, 5) = 82 Grade(4, 6) = 70 Grade(5, 1) = "小嫻" Grade(5, 2) = 86 Grade(5, 3) = 82 Grade(5, 4) = 68 Grade(5, 5) = 70 Grade(5, 6) = 64 Button1.Text = "找出動力學最高分" Button2.Text = "找出或然率最低分" Button3.Text = "求出全班總平均" End Sub ↑ 其實上面不是重點 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As _ System.EventArgs) Handles Button1.Click Dim Max As Integer = 0 Dim Who As Integer<=為什麼明明是字串他可以顯示為名字呢 Dim I As Integer For I = 1 To 5 If Grade(I, 4) >= Max Then Max = Grade(I, 4) Who = I End If Next MsgBox("動力學最高分是:" & Grade(Who, 1)) End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As _ System.EventArgs) Handles Button2.Click Dim Min As Integer = 100 Dim Who As Integer Dim I As Integer For I = 1 To 5 If Grade(I, 5) < Min Then Min = Grade(I, 5) Who = I End If Next MsgBox("或然率最低分是:" & Grade(Who, 1)) End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As _ System.EventArgs) Handles Button3.Click Dim Sum As Integer Dim Cnt As Integer Dim I, J As Integer For I = 1 To 5 For J = 2 To 6 Sum += Grade(I, J) Cnt += 1 Next Next MsgBox("全班總平均是:" & (Sum / Cnt)) End Sub End Class 謝謝大家能夠為我解答喔 |
送花文章: 1,
|
2008-12-06, 11:20 PM | #2 (permalink) |
註冊會員
|
語法:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As _ System.EventArgs) Handles Button1.Click Dim Max As Integer = 0 Dim Who As Integer<=為什麼明明是字串(整數吧....)他可以顯示為名字呢 Dim I As Integer For I = 1 To 5 If Grade(I, 4) >= Max Then Max = Grade(I, 4) Who = I End If Next MsgBox("動力學最高分是:" & Grade(Who, 1)) End Sub |
送花文章: 362,
|
|
|
相似的主題 | ||||
主題 | 主題作者 | 討論區 | 回覆 | 最後發表 |
VB的問題 | 387358 | 軟體應用問題討論區 | 2 | 2003-07-27 01:10 PM |
關於vb的問題 | SCZ | 軟體應用問題討論區 | 9 | 2003-04-24 03:34 AM |
有關於vbㄉ問題 | vincent3358 | 一般電腦疑難討論區 | 0 | 2003-04-14 09:43 PM |
請問一個VisualBasic的問題 | liang | 軟體應用問題討論區 | 0 | 2003-03-05 12:52 AM |
關於vb的問題 | superlm102 | 一般電腦疑難討論區 | 0 | 2003-02-08 03:49 PM |