在窗体上画一个文本框,然后编写如下事件过程: Private Sub Form_Click() x = InputBox("请输入一个整数") Print x + Text1.Text End Sub 程序运行时,在文本框中输入456,然后单击窗体,在输入对话框中输入123,单击“确定”按钮后,在窗体上显示的内容为( )。
在窗体上画一个文本框和一个计时器控件,名称分别为Text1和Timer1,在属性窗口中把计时器的Interval属性设置为1000,Enabled属性设置为False。程序运行后,如果单击命令按钮,则每隔一秒钟在文本框中显示一次当前的时间。以下是实现上述操作的程序: Private Sub Command1_Click() Timer1.( ) End Sub Private Sub Timer1_Timer() Text1.Text = Time End Sub 在下划线处应填入的内容是( )。
在窗体上画一个命令按钮,其名称为Command1,然后编写如下事件过程: Private Sub Command1_Click() Dim i As Integer, x As Integer For i = 1 To 6 If i = 1 Then x = i If i <= 4 Then x = x + 1 Else x = x + 2 End If Next i Print x End Sub 程序运行后,单击命令按钮,其输出结果为( )。
在窗体上画一个名称为Command1命令按钮,然后编写如下事件过程: Private Sub Command1_Click() c = “ABCD” For n= 1 To 4 Print ( ) Next End Sub 程序运行后,单击命令按钮,要求在窗体上显示如下内容 D CD BCD ABCD 则在( )处填入的内容为。
把窗体的KeyPreview属性设置为True,然后编写如下事件过程 Private Sub Form_KeyPress(KeyAscii As Integer) Dim ch As String ch = Chr(KeyAscii) KeyAscii = Asc(UCase(ch)) Print Chr(KeyAscii + 2) End Sub 程序运行后,按键盘上的“A”键,则在窗体上显示的内容是( )。
在窗体上画一个命令按钮和一个文本框,名称分别为Command1和Text1,然后编写如下程序: Private Sub Command1_Click() a=InputBox(“请输入日期(1~31)”) t=”旅游景点:” _ & IIf ( a > 0 And a <= 10,”长城”,””) _ & IIf ( a >10 And a <= 20,”故宫”,””) _ & IIf ( a > 20 And a <= 31,”颐和园”,””) Text1.Text = t End Sub 程序运行后,如果从键盘上输入16,则在文本框显示的内容是( )。
在窗体上画一个名称为Label1的标签,然后编写如下事件过程: Private Sub Form_Click() Dim arr(10, 10) As Integer Dim i As Integer, j As Integer For i = 2 To 4 For j = 2 To 4 arr(i, j) = i * j Next j Next i Label1.Caption = Str(arr(2, 2) + arr(3, 3)) End Sub 程序运行后,单击窗体,在标签中显示的内容是( )。
在窗体上画一个名称为Command1的命令按钮,然后编写如下通用过程和命令按钮的事件过程: Private Function fun(ByVal m As Integer) If m Mod 2 = 0 Then fun = 2 Else fun = 1 End If End Function Private Sub Command1_Click() Dim i As Integer, s As Integer s = 0 For i = 1 To 5 s = s + fun(i) Next Print s End Sub 程序运行后,单击命令按钮,在窗体上显示的是( )。
阅读程序: Option Base 1 Dim arr() As Integer Private Sub Form_Click() Dim i As Integer, j As Integer ReDim arr(3, 2) For i = 1 To 3 For j = 1 To 2 arr(i, j) = i * 2 + j Next j Next i ReDim Preserve arr(3, 4) For j = 3 To 4 arr(3, j) = j + 9 Next j Print arr(3, 2) + arr(3, 4) End Sub 程序运行后,单击窗体,输入结果为( )。
在窗体上画一个名称为Command1的命令按钮,然后编写如下程序: Option Base 1 Private Sub Command1_Click() Dim c As Integer, d As Integer d = 0 c = 6 x = Array(2, 4, 6, 8, 10, 12) For i = 1 To 6 If x(i) > c Then d = d + x(i) c = x(i) Else d = d - c End If Next Print d End Sub 程序运行后,如果单击命令按钮,则在窗体上输出的内容为( )。
设有如下程序: Private Sub Command1_Click() Dim c As Integer, d As Integer c = 4 d = InputBox("请输入一个整数") Do While d > 0 If d > c Then c = c + 1 End If d = InputBox("请输入一个整数") Loop Print c + d End Sub 程序运行后,单击命令按钮,如果在输入对话框中依次输入1、2、3、4、5、6、7、8、9、0,则输出结果是( )。
在窗体上画一个名称为Command1的命令按钮和一个名称为Text1的文本框,在文本框中输入以下字符串:Microsoft Visual Basic Programming 然后编写如下事件过程: Private Sub Command1_Click() Open "d:\temp\outf.txt" For Output As #1 For i = 1 To Len(Text1.Text) c = Mid(Text1.Text, i, 1) If c >= "A" And c <= "Z" Then Print #1, LCase( End If Next i Close End Sub 程序运行后,单击命令按钮,文件outf.txt中的内容是( )。
在窗体上画一个名称为Command1的命令按钮,然后编写如下程序: Dim SW As Boolean Function func(X As Integer) As Integer If X < 20 Then Y = X Else Y = 20 + X End If func = Y End Function Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) SW = False End Sub Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) SW = True End Sub Private Sub Command1_Click() Dim intNum As Integer intNum = InputBox("") If SW Then Print func(intNum) End If End Sub 程序运行后,单击命令按钮,将显示一个输入对话框,如果在输入对话框中输入25,则程序的执行结果为( )。
设有如下通用过程: Public Sub Fun(a() As Integer, x As Integer) For i = 1 To 5 x = x + a(i) Next End Sub 在窗体上画一个名称为Text1的文本框和一个名称为Command1的命令按钮。然后编写如下的事件过程: Private Sub Command1_Click() Dim arr(5) As Integer, n As Integer For i = 1 To 5 arr(i) = i + i Next Fun arr, n Text1.Text = Str(n) End Sub 程序运行后,单击命令按钮,则在文本框中显示的内容是( )。
在窗体上画一个文本框和一个图片框,然后编写如下两个事件过程: Private Sub Form_Click() Text1.Text = "VB程序设计" End Sub Private Sub Text1_Change() Picture1.Print "VB Programming" End Sub 程序运行后,单击窗体,则在文本框中显示的内容是 ______ ,而在图片框中显示的内容是 ______ 。
阅读下面的程序: Private Sub Form_Click() Dim Check As Boolean, Counter As Integer Check = True Counter = 5 Do Do While Counter < 20 Counter = Counter + 1 If Counter = 10 Then Check = False Exit Do End If Loop Loop Until Check = False Print Counter End Sub 程序运行后,单击窗体,输出结果为 ______ 。
设有如下程序: Private Sub Form_Click() Dim n As Integer, s As Integer n = 8 s = 0 Do s = s + n n = n - 1 Loop While n > 0 Print s End Sub 以上程序的功能是 ______ 。程序运行后,单击窗体,输出结果为 ______ 。
设有如下程序: Option Base 1 Private Sub Command1_Click() Dim arr1 Dim Min As Integer, i As Integer arr1 = Array(12, 435, 76, -24, 78, 54, 866, 43) Min = ______ For i = 2 To 8 If arr1(i) < Min Then ______ Next Print "最小值是:"; Min End Sub 以上程序的功能是:用Array函数建立一个含有8个元素的数组,然后查找并输出该数组中各元素的最小值。请填空。
在名称为Form1的窗体上画一个文本框,其名称为Text1,在属性窗口中把该文本框的MultiLine属性设置为True,然后编写如下的事件过程: Private Sub Form_Click() Open "d:\test\smtext1.txt" For Input As #1 Do While Not ______ Line Input #1, aspect$ whole$ = whole$ + aspect$ + Chr$(13) + Chr$(10) Loop Text1.Text = whole$ Close #1 Open "d:\test\smtext2.txt" For Output As #1 Print #1, ______ Close #1 End Sub 上述程序的功能是,把磁盘文件smtext1.txt的内容读到内存并在文本框中显示出来,然后把该文本框中的内容存入磁盘文件smtext2.txt。请填空。