窗体中有命令按钮Commandl,事件过程如下: Public Function f(x As Integer) As Integer Dim y As Integer x=20 y=2 f=x*y End Function Private Sub Commandl_Click() Dim y As Integer Static x As Integer x=10 y=5 y=f(x) Debug .Print x;y End Sub 运行程序,单击命令按钮,则立即窗口中显示的内容是
窗体中有命令按钮Commandl和文本框Text1,事件过程如下: Function result(ByVal x As Integer)As Boolean If ×Mod 2=0 Then result=True Else result=False End If End Function Private Sub Commandl_Click() x=Val(InputBox(“请输入一个整数”)) If______ Then Text1=Str(x)&“是偶数.” Else Text1=Str(x)&“是奇数.” End If End Sub 运行程序,单击命令按钮,输入19,在Text1中会显示“19是奇数”.那么在程序的空白处应填写
窗体有命令按钮Commandl和文本框Textl,对应的事件代码如下: Private Sub Commandl_Click( ) For i=1 To 4 x=3 For j=1 To 3 For k=1 To 2 x=x+3 Next k Next j Next i Text1 .Value=Str(x) End Sub 运行以上事件过程,文本框中的输出是
窗体中有命令按钮run34,对应的事件代码如下: Private Sub run34_Enter() Dim num As Integer,a As Integer,b As Integer,i As Integer For i=1 To 10 num=InputBox(“请输入数据:”,“输入”) If Int(num/2)=num/2 Then a=a+1 Else b=b+1 End If Next i MsgBox(“运行结果:a=”&Str(a)&“,b=”&Str(b)) End Sub 运行以上事件过程,所完成的功能是
运行下列程序,输入数据8, 9, 3, 0后,窗体中显示结果是 Private Sub Form _click() Dim sum AsInteger,m As Integer sum=0 Do m=InputBox(“输入m”) sum=sum+m Loop Until m=0 MsgBox sum End Sub
一下列程序的功能是求方程:x2十y2=1000的所有整数解。请在空白处填入适当的语句,使程序完成指定的功能。 Private Sub Commandl_Click() Dim × as integer,y as integer For x= -34 To 34 For y= -34 To 34 If__Then Debug .Print x,y End If Next y Next x End Sub
下列程序的功能是求算式:1+1/2 ! +1/3!+1/4!+……前10项的和(其中n!的含义是n的阶乘)。请在空白处填入适当的语句,使程序完成指定的功能。 Private Sub Commandl_Click() Dim i as integer,s as single,a as single a=1:s=0 For i=1 To 10 a=__ s=s+a Next i Debug .Print “1+1/2!十1/3!+. …=”;s End Sub
在窗体中有一个名为Command12的命令按钮,Click事件功能是:接收从键盘输入的10个大于0的不同整数,找出其中的最大值和对应的输入位置。请在空白处填入适当语句,使程序可以完成指定的功能。 Private Sub Command12_Click() max=0 maxn=0 for i=1 To 10 num=Val(InputBox(‘,请输入第“&i&”个大于0的整数:“)) If__Then max=num maxn=__ End If Next i MsgBox(”最大值为第“&maxn&”个输入的“&max) End Sub
数据库的”职I基本情况表“有”姓名“和”职称“等字段,要分别统计教授、副教授和其他人员的数量。请在空白处填入适当语句,使程序可以完成指定的功能。 Private Sub Commands_Click() Dim db As DAO .Database Dim rs As DAO .Recordset Dim zc As DAO .Field Dim Countl As Integer,Count2 As Integer,Count3 As Integer Set db=CurrentDb() Set rs=db .OpenRecordset(”职工基本情况表“) Set zc=rs .Fields(”职称“) Countl=0 : Count2=0 : Count3=0 Do While Not__ Select Case zc Case Is=”教授“ Countl=Countl+1 CaseIs=”副教授“ Count2=Count2+1 Case Else Courit3=Count3+1 End Select __ Loop rs .Close Set rs=Nothing Set db=Nothing MsgBox”教授:“&Count1&”,副教授:“&Count2 &”,其他:“&count3 End Sub