在窗体上画1个名称为Command1和命令按钮和2个名称分别为Text1、Text2的文本框,如图所示,然后编写如下程序:
Function Fun(X As Integer,ByVal y As Integer)As Integer
x=x+y
If X<0 Then
Fun=x
Else
Fun=y
End If
End Function
Private Sub Command1 Click()
Dim a As Integer,b As Integer
a=-10:b=5
Text1.Text=Fun(a,B)
Text2.Text=Fun(a,B)
End Sub
程序运行后,单击命令按钮,Text1和Text2文本框显示的内容分别是()和()。
在窗体上画1个命令按钮,其名称为Command1,然后编写如下事件过程:
Private Sub Command1_Click()
Dim arr(1 To 100)As Integer
For i=1 To 100
arr(i)=Int(Rnd*1000)
Next i
Max=arr(1)
Min=arr(1)
For i=1 To 100
If () Then
Max=arr(i)
End If
If () Then
Min=arr(i)
End If
Next i
Print "Max=";Max,"Min=";Min
End Sub
程序运行后,单击命令按钮,将产生100个1000以内的随机整数,加入数组arr中,然后查找并输出这100个数中的最大值Max和最小值Min,请填空。
下列语句的输出结果是()。
Print Format(Int(12345.6789* 100+0.5)/100,"0000,0.00")
在窗体上画1个文本框,名称为Text1,然后编写如下程序:
Private Sub Form_Load()
Open "d:\temp\dat.txt" For Output As #1
Text1.Text=" "
End Sub
Private Sub Text1 KeyPress(KeyAscii As Integer)
If ()=13 Then
If UCase(Text1.Text)=() Then
Closer #1
End
Else
Write #1,()
Text1.Text=" "
End If
End If
End Sub
以上程序的功能是,在D盘temp目录下建立1个名为dat.txt的文件,在文本框中输入字符,每次按回车键(回车符的ASCII码是13)都把当前文本框中的内容写入文件dat.txt,并清除文本框中的内容;如果输入“END”,则结束程序。请填空。