tStr = ""
strL = Len(xStr)
i = 1
Do While i <= strL / 2
tStr = tStr & Mid(xStr, i, 1) & Mid(xStr, strL - i + 1, 1)
i = i + 1
Loop
Fun = tStr
End Function
在窗体上画一个名称为Text1的文本框和一个名称为Command1的命令按钮。然后编写如下的事件过程:
Private Sub Command1_Click()
Dim S1 As String
S1 = "abcdef"
Text1.Text = UCase(Fun(S1))
End Sub
程序运行后,单击命令按钮,则Text1中显示的是
A)ABCDEF B)abcdef C)AFBECD D)DEFABC
(28)在窗体上画一个名称为TxtA的文本框,然后编写如下的事件过程:
Private Sub TxtA_KeyPress(KeyAscii As Integer)
......
End Sub
假定焦点已经位于文本框中,则能够触发KeyPress事件的操作是
A)单击鼠标 B)双击文本框
C)鼠标滑过文本框 D)按下键盘上的某个键
(29)在窗体上画一个命令按钮和两个文本框,其名称分别为Command1、Text1和Text2,然后编写如下程序:
Dim S1 As String, S2 As String
Private Sub Form_Load()
Text1.Text = ""
Text2.Text = ""
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
S2 = S2 & Chr(KeyCode)
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
S1 = S1 & Chr(KeyAscii)
End Sub
Private Sub Command1_Click()
Text1.Text = S2
Text2.Text = S1
S1 = ""
S2 = ""
End Sub
程序运行后,在Text1中输入“abc”,然后单击命令按钮,在文本框Text1和Text2中显示的内容分别为
A)abc和ABC B)abc和abc C)ABC和abc D)ABC和ABC
(30)以下说法中正确的是
A)任何时候都可以通过执行“工具”菜单中的“菜单编辑器”命令打开菜单编辑器
B)只有当某个窗体为当前活动窗体时,才能打开菜单编辑器
C)任何时候都可以通过单击标准工具栏上的“菜单编辑器”按钮打开菜单编辑器
D)只有当代码窗口为当前活动窗口时,才能打开菜单编辑器
(31)在窗体上画一个通用对话框,其名称为CommonDialog1,然后画一个命令按钮,并编写如下事件过程:
Private Sub Command1_Click()
CommonDialog1.Filter = "All Files (*.*)|*.*|Text Files" & _
"(*.txt)|*.txt| Executable Files(*.exe)|*.exe"
CommonDialog1.FilterIndex = 3
CommonDialog1.ShowOpen
MsgBox CommonDialog1.FileName |