兩道例項希望對你的問題有所幫助(VB):1.隨機產生10個100~200之間的整數,求最大值Private Sub Command1-Click() Max = 100 For i =1 To 100 x=Int(Rnd*101+100) Print x; If x > Max Then Max = x Next i Print Print"最大值”; Max End Sub2用Array 函式建立的含有8個數組元素的陣列,然後查詢並輸出陣列中最大值Option Base 1Private Sub Command1-Click() Dim arrl , Max as Integer arrl = Array(12,435,76,24,78,54,866,43) Max= arrl(1) For i =1 To 8 If arrl(i) > Then Max =arrl(i) Next i Print"最大值”; Max End Sub
兩道例項希望對你的問題有所幫助(VB):1.隨機產生10個100~200之間的整數,求最大值Private Sub Command1-Click() Max = 100 For i =1 To 100 x=Int(Rnd*101+100) Print x; If x > Max Then Max = x Next i Print Print"最大值”; Max End Sub2用Array 函式建立的含有8個數組元素的陣列,然後查詢並輸出陣列中最大值Option Base 1Private Sub Command1-Click() Dim arrl , Max as Integer arrl = Array(12,435,76,24,78,54,866,43) Max= arrl(1) For i =1 To 8 If arrl(i) > Then Max =arrl(i) Next i Print"最大值”; Max End Sub