現(xiàn)要求編寫VB程序(運(yùn)行界面如圖所示),實(shí)現(xiàn)如下功能:在文本框text1中輸入x的值,單擊“計(jì)算”按鈕command1,在標(biāo)簽label3中顯示y的值. 按此要求編寫的程序如下,解決此問題的相應(yīng)程序如下,請(qǐng)根據(jù)題意,在橫線處填入合適的代碼. Function f(x As Single) As Single If x<0Then f=-x ElseIf ①Then f=(3*x*x+1)/(3*x-2) Else f=Sqr(3*x*x-2*x+1) End If End Function Private Sub Command1_Click( ) Dim x As Single,y As Single x=Val(Text1.Text) ② Label3.Caption=Str(y) End Sub 程序中①橫線處應(yīng)填入
屬性的屬性值改為“角谷猜想”. (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’與下一行語句同行 month=8Or month=10Or month=12)And day>31Then hefa=False If (month=4Or month=6Or month=9Or month=11)’與下一行語句同行 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.