. Dim a(1 to 10)As Integer Private Sub form-Load( ) '產(chǎn)生10個隨機整數(shù),并顯示在標簽Label1中 End sub Private Sub answer-Click( ) Dim i As Integer,max As Integer,t As Integer,dz As Integer Max=0:t=1:dz=0 For i='① If a(i)<a(i+1)Then '② Else If max<t Then max=t If t>1 Then dz=dz+1:t=1 End If Next i '以下程序代碼處理最后幾個數(shù)正好屬于升序序列的情況 If t>1 Then If max<t Then max=t dz=dz+1 End If Text1.Text=Str(dz) Text2.Text=Str(max) End Sub.
17.某省學(xué)生信息技術(shù)學(xué)習平臺使用情況數(shù)據(jù)存儲在數(shù)據(jù)庫中,利用VB編寫一個程序,實現(xiàn)的功能:輸入一個積分的范圍,顯示該范圍內(nèi)的學(xué)生編號和對應(yīng)的積分.程序運行界面如圖所示: 程序代碼如下,為實現(xiàn)以上功能,請在橫線處填寫合適的代碼: Dim bh(10000)As String‘存儲學(xué)生編號 Dim jf(10000)As Integer‘存儲學(xué)生獲得的積分值 Dim n As Integer‘存儲學(xué)生總?cè)藬?shù) Function Search(x As Integer)As Integer Search=0 i=1:j=n:flag=True Do While i<=j And flag=True m=Int((i+j)/2) If x=jf(m) Then flag=False
Elsef
Then i=m+1 End If Loop End Function Private Sub Form-Load( ) ‘從數(shù)據(jù)庫中讀取學(xué)生編號和積分,分別存儲到bh數(shù)組和jf數(shù)組中,并按積分值從小到大排序,顯示在列表框Listl中 End Sub Private Sub Commandl-Click( ) Dim Top As Integer,Bottom As Integer,Topxb As Integer,Bottomxb As Integer List2.Clear Top=Val(Text2.Text) If Top>Bottom Then t=Top:Top=Bottom:Bottom=t If Top>jf(n) Or Bottom<jf(1)Then Exi Sub Do While Search(Top)=0 Top=Top+1 Loop Do While Search(Bottom)=0 Bottom=Bottom-1 Loop Topxb=Search(Top) Do While jf(Topxb)=jf(Topxb-1)And Topxb>1 Topxb=Topxb-1 Loop Bottomxb=Search(Bottom) Do while jf(Bottomxb)=jf(Bottomxb+1)And Bottomxb<n Bottomxb=Bottomxb+1 Loop For i=