
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
划线①、②处的选项: Ⅰ.i <= t2 Ⅱ.f <= t2 Ⅲ.t1 > t2 Ⅳ.i < f

Private Sub Command1_Click()
Dim S As String
Dim n As Integer
Dim cnt As Integer
Dim i As Integer
Dim num As Single
Dim cd As Single
Dim ave As Single
s=Text1.Text
n=Len(s)
hum=0
cd=0
cnt=0
For i=1 To n
①
If c>“a”And c<=“z” Or c>=“A”And c<=“Z”Then
cnt=cnt+1
Elself c>=”0”And c<=”9”Then
cnt=cnt+1
Else
If cnt>0 Then
num=num+1
cd=cd+cnt
②
End If
End If
Next i
If cnt>0 Then
num=num+1
cd=cd+cnt
End If
Ave=cd/num
Label1.Caption=“总共有”+Str(num)+“个单词,平均长度为”+Str(ave)
End Sub
① ②
小明编写了一个VB程序来计算e的近似值,功能为在文本框Text1中输入公式n值,单击“计算”命令按钮Commong1,在标签Label2中显示计算结果,程序运行界面如图所示。
Private Sub Command1_Click()
Dim i As Double,p As Double
Dim e As Double
n= ①
e=1
i=1
p=1
Do While i<=n
p= ②
e=e+p
③
Loop
Label2.Caption=”e的值是:”+Str(e)
End Sub
① ② ③
鞋子尺码换算:常用的两种鞋码一种是欧制的码m,而我国采用的标准为厘米数g,鞋子尺码的换算公式:欧制m=中国制g*2-10。例如25是我国采用的厘米数,换算成欧制的码为25*2-10=40(码)。
Private Sub Command1_Click()
Dim g1 As Integer, g2 As Integer
Dim i As Integer, temp As Integer
Dim m As Single
List1.Clear
g1 = Val(Text1.Text)
g2 = Val(Text2.Text)
IfThen
temp = g1: g1 = g2: g2 = temp
End If
i = g1
Do While i <= g2
List1.AddItem Str(i) + “” + Str(m)
i = i + 1
Loop
End Sub
小明编写了一个VB程序来计算e的近似值,功能为在文本框Text1中输入公式n值,单击“计算”命令按钮Command1,在标签Labe2中显示计算结果,程序运行界面如图所示。
Private Sub Command1__Click()
Dim I As Double,p As Double
Dim e As Double
n= ①
e=1
i=1
p=1
Do While i<=n
p= ②
e=e+p
③
Loop
Label2. Caption=“e的值是:”+Str(e)
End Sub
① ② ③
Private Sub Command1_Click( )
Dim i As Integer, s As String, flag As Boolean
①
flag True: i=2
Do While i <= Len (s) And flag
②
i=i+1
③
If flag Then
Label2. Caption=s+ “是降序数!”
Else
Label2.Caption=s+ “不是降序数!”
End If
End Sub
① ② ③
Private Sub Command1_Click()
Dim result As String, s As String, c As String, cmax as string
Dim i As Integer, j As Integer
s = Text1.Text
Text2.Text = ""
For i = 1 To Len(s)
①
If c >= "A" And c <= "Z" Or c >= "a" And c <= "z" Then
result =②
End If
Next i
Text2.Text = result
j = 2
cmax = Mid(result, 1, 1)
Do While j <= Len(result)
If Mid(result, j, 1) > cmax Then cmax = Mid(result, j, 1)
③
Loop
Text3.Text = cmax
End Sub
Const n = 10 ‘n 名学生
Dim a(1 To n) As Integer ‘存放身高
Dim b(1 To n) As String ‘存放性别
Private Sub Form_Load()
'读取身高和性别数据,分别存储在数组a和b中,代码略
For i = 1 To n
List1.AddItem b(i) + Str(a(i))
Next i
End Sub
Private Sub Command1_Click()
Dim i As Integer, j As Integer, k As Integer, t As Integer
Dim s As String
i = 1:
Do While i<j
For k = i To j
If Then
If b(i) = "女" Or a(i) > a(k) Then
s = b(k): b(k) = b(i): b(i) = s
t = a(k): a(k) = a(i): a(i) = t
End If
Else
If
Then
s = b(k): b(k) = b(j): b(j) = s
t = a(k): a(k) = a(j): a(j) = t
End If
End If
Next k
If b(i) = "男" Then i = i + 1
If b(j) = "女" Then
Loop
For i = 1 To n
List2.AddItem b(i) + Str(a(i))
Next i
End Sub
小罗编写VB程序实现上述功能:程序运行时,读取所有城市数据保存在变量shuju中并显示在列表框List1中。在文本框Text1中输入“南区”或“北区”,文本框Text2中输入n的值,单击“排名”按钮Command1,对数据进行统计分析,并在列表框List2中显示治愈率最高的n个城市,如有与第n个城市相同治愈率的城市,则同时输出。程序运行界面如图所示,请回答下列问题。
Dim shuju As String, a(1 To 100) As String
Dim t As Integer, i As Integer, j As Integer, c As String, p As Integer, temp As String, q as String Dim f As Boolean, n As Integer, k As Integer
'读取所有城市数据保存在变量shuju中,并显示在列表框List1中,代码略
t = Len(shuju)
i = 1: p = 0: j = 1
Do While i <= t
c = Mid(shuju, i, 1)
If c = "/" Or c = ";" Then
p = p + 1
a(p) = j = i + 1
End If
i = i + 1
Loop
q = Text1.Text : n = Val(Text2.Text) : i = 1
Do While i <= p \ 4 - 1
k = i
IfThen f = True Else f = False
For j = i + 1 To p \ 4
If a(4 * j - 3) = q Then
If Val(a(4 * j)) / Val(a(4 * j - 1)) > Val(a(4 * k)) / Val(a(4 * k - 1)) Or Not f Then k = j
End If
End If
Next j
If k <> i Then
temp = a(4 * k - 3): a(4 * k - 3) = a(4 * i - 3): a(4 * i - 3) = temp
temp = a(4 * k - 2): a(4 * k - 2) = a(4 * i - 2): a(4 * i - 2) = temp
temp = a(4 * k - 1): a(4 * k - 1) = a(4 * i - 1): a(4 * i - 1) = temp temp = a(4 * k): a(4 * k) = a(4 * i): a(4 * i) = temp
End If
If
Then
List2.AddItem a(4*i-3) & "/" & a(4*i-2) & "/" & Format(Val(a(4*i)) / Val(a(4*i-1)), "0.00%") & ";"
i = i + 1
Else
Exit Do
End If
Loop
End Sub
其中“BackColor”是( )
Private Sub Command1_Click( )
Dim a As Integer,s As String
Dim n As Integer,t As Integer,v As Integer
n=Val(Text1.Text)
t=0
s=""
Do While n>0
a=n Mod 2
n=n\2
t= ①
s=Str(a)+s
Loop
v=t Mod 2
Text2.Text=s
Label3.Caption="校验位值:"+ ②
End Sub
以上程序段运行时,为了实现上述功能,画线处应填入的代码分别为:①;②。
Private Sub Judge_Click( )
Dim x As Integer, i As Integer
Dim y As Long, flag As Boolean
flag = False
x = Val(Text1.Text)
i = 10
Label2.Caption = "该数的平方是:" + Str(y)
Do While y \ i > 0 And flag = False
t1 = y \ i
t2 = y Mod i
If Then
flag = True
Label3.Caption = Str(t1) + "+" + Str(t2) + " = " + Str(x)"
End If
i =
Loop
If Not flag Then Label3.Caption = "该数不是卡普利加数"
End Sub
Private Sub Command1_Click()
Dim s1, s2, d As String
Dim i As Integer
s1 = Text1.Text
①
i = 1
Do While i<= Len(s1)
s = Mid(s1, i, Len(d))
If s = d Then
②
Else
s2 = s2 + ③
i = i + 1
End If
Loop
Text3.Text = s2
End Sub
① ② ③
Private Sub Command1_Click()
Dim s As String, s1 As String, s2 As String
Dim c As Integer, k As Integer, i As Integer, flag As Boolean
flag = False
s = Text1.Text
For c = 1 To Len(s)
If Then Exit For 'Exit for退出循环
Next c
s1 = Mid(s, 1, c - 1)
s2 = Mid(s, c + 1,len(s)-c)
k =
For i = 1 To k - 1
If Val(Mid(s1, 1, i)) + Val(Mid(s1, i + 1,c-i-1)) = Val(s2) Then
List1.AddItem Mid(s, 1, i) + "+" + Mid(s, i + 1,len(s)-i)
End If
Next i
If Not flag Then List1.AddItem "等式始终无法成立!"
End Sub

Private Sub Command1_Click()
Dim i As Integer, j As Integer, n As Integer, ¥ As Integer
Dim s As String, ch As String, c1 As String, c2 As String
s=Text1.Text:k=1:j=1
For i=1 To Len(s)
ch=Mid(s,i,1)
If ch< "0" Or ch>"g" Then
v=
'变量v截取s中的每段数字
j=i+1
If k =1 Then
n1=v:c1=ch
ElseIf k = 2 Then
n2=v:c2=ch
Else
①
If c1 ="*" And c2 = "*" Then
n1=n1*n2:n2=n3
c2=ch
ElseIf c1 = "*" And c2 =" +" Then
n1=n1*n2:n2=n3
c1 ="+": c2= ch
ElseIf c1= "+"And c2 =' "*" Then
②
c2=ch
Else
n1=n1+n2:n2=n3
c2=ch
End If
End If
K=k+1
End If
Next i
If c1="*"Then n1=n1*n2 Else n1=n1+n2
Text2.Text = Str (n1)
End Sub
请回答以下问题。
① ②
实现上述功能的VB代码如下,但加框处有错,请改正。
Private Sub Command1_Click()
Dim n As Integer,m As Integer
Dim a(1 To 50)As Integer
n= Val(Text1. Text)
m= Val(Text2. Text)
For i= 1 To n
Next i
s=0;j=0
Do While s <n
t=0
Do While t <m
t=t+ a(j)
Loop
a(j)=0
s=s+1
List1. Additem"第"+Str(s)+"次:"+Str(j)
Loop
End sub
应改为