t = "abcd123456"
x = Sqr(Len(t))
y = 0
If x >0 Then
y = 2
ElseIf x >1 Then
y = 3
ElseIf x >2 Then
y = 4
Else
y = 5
End If
Dim i As Integer, Sum As Integer
Dim a(1 To 11) As Integer
Sum = 6
a(11) = 49
For i = 10 To 1 Step -1
a(i) = a(i +1) -1
If a(i) Mod 3 = 0 Then Sum = Sum + a(i)
Next i
Text1.Text = Str(Sum)
Text1.Text = "0"
For i = 2 To 9
k = 0
For j = 1 To i -1
If a(j) < a(i) Then k = k +1
Next j
Text1.Text = Text1.Text + "," + Str(k)
Next i
已知数组a的数据序列为2,10,3,4,5,7,0,9,12,则该程序段运行后,文本框Text1中显示的内容是 ( )
Dim R As Integer,xAsInteger,yAsInteger
Do While ①
r =x Mod y
x = y
y = r
Loop
②
则划线①②两处填入的代码为 ( )
i = 1: n = 5
Do While i <= n
x = Int(Rnd * 9) + 1
If x Mod 2 = 1 Then
a(i) = x
Else
a(n) = x
n = n - 1
End If
i = i + 1
Loop
数组元素的初值均为0,执行该程序段后,在下列选项中a(1)至a(5)各元素值可能的是( )
图b
图 b
1图
2图
Private Sub Command1_Click()
Dim t1 As Integer, t2 As Integer
Dim i As Integer, t As Integer
Dim f As Single
List1.Clear
t1 = Val(Text1.Text)
t2 = Val(Text2.Text)
If ① Then
t = t1: t1 = t2: t2 = t
End If
i = t1
Do While ②
f = i * 9 / 5 + 32 '摄氏温度转换为华氏温度
List1.AddItem Str(i) + " " + Str(f)
Loop
End Sub
A.i <= t2 B.f <= t2 C.t1 > t2 D. i < f
① ②
编写解密的VB程序,功能如下:在文本框Text1中输入密文,单击“解密”按钮Command1,在文本框Text2中显示去重后的文本,并在标签Label1中显示明文。程序运行界面如下图所示。
Private Sub Command1_Click()
Dim s1 As String, s2 As String, c As String, mw As String
Dim i As Integer
s1 = Text1.Text
s2 = Mid(s1, 1, 1)
For i = 2 To
c = Mid(s1, i, 1)
If c >= "A" And c <="Z" Then
If Then s2 = s2 + c
Else
s2 = s2 + c
End If
Next i
mw = " "
i = 6
Do While i <= Len(s2)
mw = mw+Mid(s2, i, 1)
Loop
Text2.Text = s2
Label1.Caption = mw
End Sub