16.(1)某省實(shí)施《中華人民共和國道路交通安全法》辦法中規(guī)定,機(jī)動(dòng)車駕駛?cè)笋{駛機(jī)動(dòng)車超過規(guī)定時(shí)速但未超過百分之五十的,處予二百元罰款.超過百分之五十(未造成交通事故)的,處五百元罰款,每多超過五公里,加處二百元罰款,不足五公里的忽略不計(jì),但最高罰款不得超過二千元.用于計(jì)算罰款額的Visual Basic程序如下: Private Sub Command1_Click ( ?。?br />Dim v0As Integer,v As Integer,x As Integer v0=Val(Text1.Text)'v0 存儲規(guī)定速度 v=Val(Text2.Text)'v存儲實(shí)際速度 If v>v0And v<=1.5*v0Then x=200 ElseIf v>1.5*v0Then x=500+Int((v-1.5*v0)/5)*200 Else x=0 End If If x>2000Then x=2000 Label1.Caption=Str(x) End Sub 運(yùn)行該程序時(shí),在Text1文本框中輸入50,在Text2文本框中輸入60,點(diǎn)擊Command1時(shí),在Label1的Caption上顯示的罰款金為
. (2)如下一段Visual Basic程序: Private Sub Command1_Click( ?。?br />Dim i As Integer,sum As Integer Dim x As Integer,n as Integer n=Val(Text1.text) sum=0 For i=1To n x=Int(Sqr(i)) If x*x=i Then sum=sum+x Next i Label1.Caption=Str(sum) End Sub 在Text1框中輸入10時(shí),點(diǎn)擊Command1時(shí),Label1上顯示的是
程序如下: Dim a(1To 8)As Integer Dim n,i,j,x As Integer Private Sub Command1_Click( ?。?br />x=Val(Text2.Text) If x>a(n) Then i=n+1 else i=1 Do While x>a(i) i=i+1 Loop End If Text3.text=str(i)‘在文本框text3 顯示名次 End Sub Private Sub Text1_KeyPress(KeyAscii As Integer 輸出 If KeyAscii=13Then n=n+1 a(n)=Val(Text1.Text) List1.AddItem Str(a(n)) Text1.Text=““:Text1.SetFocus‘準(zhǔn)備在text1 接受下一個(gè)數(shù)據(jù) End If End Sub.