close
etUpperBound & GetLowerBound係陣列常用的方法
上一篇文章中提到陣列係一數列,可使用GetUpperBound & GetLowerBound來取數列的上下限
GetUpperBound(0) 是取得第一維陣列維度上限
GetUpperBound(1) 是取得第二維陣列維度上限
GetLowerBound(0) 是取得第一維陣列維度下限
GetLowerBound(1) 是取得第二維陣列維度下限
(陣列下限的維度由0開始)
Public Class Form1
Dim student_score() As Integer = {100, 90, 80}
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim upper As Integer = student_score.GetUpperBound(0)
Dim lower As Integer = student_score.GetLowerBound(0)
For num = lower To upper
ListBox1.Items.Add("第" & num & "位的學生成績為" & student_score(num))
Next
End Sub
End Class
全站熱搜
留言列表