小明設(shè)計(jì)了一個(gè)VB程序(界面如圖所示),隨機(jī)產(chǎn)生n(n<=100)個(gè)大于等于a(a<=100)且小于等于b(b<=100)的整數(shù),并在列表框List1中降序顯示. 實(shí)現(xiàn)上述功能的VB代碼如下: 請(qǐng)?jiān)跈M線處填入合適代碼. Private Sub Command1_Click( ?。〥im a As Integer,b As Integer Dim n As Integer,t As Integer Dim m(1To 100)As Integer a=Val(Text1.Text) b=Val(Text2.Text) n=Val(Text3.Text) If a>b Then t=a:a=b:b=t Randomize ①
m(1)=Int(Rnd*(b-a+1))+a
m(1)=Int(Rnd*(b-a+1))+a
For i=2To n m(i)=Int(Rnd*(b-a+1))+a If m(i)>m(i-1)Then ②
temp=m(i)
temp=m(i)
For j=i-1To 1Step-1 If temp<m(j) Then Exit For m(j+1)=m(j) Next j ③
m(j+1)=temp
m(j+1)=temp
End If Next i For i=1To n List1.AddItem Str(m(i)) Next i End Sub 程序①處的代碼是
屬性的屬性值改為“角谷猜想”. (2)為實(shí)現(xiàn)上述功能,請(qǐng)?jiān)跈M線處填入合適代碼. Private Sub Command1_Click ( ?。?br />Dim x As Long x=Val(Text1.Text)'將text1中的內(nèi)容賦值給x Do While x<>1 If
Then'x為奇數(shù)的情況 x=x*3+1 Else'x為偶數(shù)的情況 x=
List1.AddItem“x=“& Str(x)'將x的變化添加到list1上 Loop End Sub 橫線處①應(yīng)填入
.(單選,填字母:A.Text1/B.List1/C.Command1/D.Judge/E.判斷) (2)為實(shí)現(xiàn)上述功能,請(qǐng)?jiān)跈M線處填入合適的代碼. Private Sub Judge_Click( ?。〥im riqi As String,st As String Dim year As Integer,month As Integer,day As Integer Dim rn As Boolean,hefa As Boolean riqi=Text1.Text year=Val(Mid(riqi,1,4)) month=Val(Mid(riqi,5,2)) day=①
Then rn=True‘第②處 If year Mod 4=0And year Mod 100<>0Then rn=True hefa=True‘用于判斷是否為合法日期 If month=0Or month>12Then hefa=False If day=0Then hefa=False If (month=1Or month=3Or month=5Or month=7Or’與下一行語(yǔ)句同行 month=8Or month=10Or month=12)And day>31Then hefa=False If (month=4Or month=6Or month=9Or month=11)’與下一行語(yǔ)句同行 And day>30Then hefa=False If ③
Then hefa=False ’第③處,判斷閏年2月的天數(shù)是否合法 If month=2And Rn=False And day>28Then hefa=False If hefa=True Then st=st+“合法日期“Else st=st+“非法日期“ List1.AddItem st End Sub.