1 / 5

陣列補充

陣列補充. 設定陣列元素的值. 設定一維陣列元素的值 ( 五筆資料 ) 方法一: Dim score() As Integer = {23, 88, 77, 35, 99, 66} 方法二: Dim score(5) As Integer score = {23, 88, 77, 35, 99, 66} 方法三: Dim score(5) As Integer For i = 0 To 4 score(i) = InputBox(" 請輸入第 " & i & " 科成績 ") Next. 顯示輸出結果. 顯示輸出結果的方式 顯示結果方法一

Download Presentation

陣列補充

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 陣列補充

  2. 設定陣列元素的值 設定一維陣列元素的值(五筆資料) 方法一: Dim score() As Integer = {23, 88, 77, 35, 99, 66} 方法二: Dim score(5) As Integer score = {23, 88, 77, 35, 99, 66} 方法三: Dim score(5) As Integer For i = 0 To 4 score(i) = InputBox("請輸入第" & i & "科成績") Next

  3. 顯示輸出結果 顯示輸出結果的方式 顯示結果方法一 Label1.Text = "" For i = 0 To 4 Label1.Text &= "第" & i + 1 & "號" & score(i) & "分" & ControlChars.CrLf ‘vbcrlf Next Label1.Text &= "最高分為:" & max & ControlChars.CrLf 顯示結果方法二 For i = 0 To 4 Controls("Label" + (i + 1).ToString).Text = "第" & i + 1 & "號" & score(i) & "分" & vbcrlf Next Label6.Text = "最高分為:" & max & ControlChars.CrLf

  4. 作業 • 一維:最高分、最低分、總和、平均值、不及格人數 • 改寫成二維陣列 • 彷p.213將p.288的成績加上(針對不同科目) • 計算總分 • 計算平均 • 最高分 • 最低分 • 不及格人數 • 改寫血型及星座(找出最速配指數) • 完成P.216

  5. For i = 0 To 23 For j = 0 To 59 TextBox1.Text = i & " 時" & j & " 分" Next Next 外迴圈 內迴圈 五、巢狀迴圈敘述 • 巢狀迴圈敘述:迴圈敘述中還有迴圈敘述 • 例:

More Related