Private Sub Command1_Click( )
Dim c1 As String, c2 As String, s1 As String, s2 As String
s1 = Text1.Text: s2 = Text2.Text
i = 1: j = 1
Do While i <= Len(s1) And j <= Len(s2)
c1 = Mid(s1, i, 1): c2 = Mid(s2, j, 1)
If Then
i = i + 1: j = j + 1
Else
Exit Do 'Exit Do表示退出循环
End If
Loop
If i > Len(s1) And j > Len(s2) Then T3.Text = "相同" Else T3.Text = "不相同"
End Sub
Function toLowerCase(x As String) As String '该函数把大写字母转成小写
If x >= "A" And x <= "Z" Then
toLowerCase = Chr(Asc(x) + 32)
Else
End If
End Function
划线处的代码从以下代码中选择,每条划线一句代码:
①toLowerCase = Chr(Asc(x) - 32) ②toLowerCase = x
③toLowerCase(c1) = toLowerCase(c2) ④c1 = c2
选择代码组合正确的是
Dim n As Integer, i As Integer, m As Integer, s As String, temp As String
Dim a(1 to 300) As String, b(1 to 7) As Integer
Private Sub Form_Load()
'读取每位同学的选课科目,保存到数组a(1 to 300)中,代码略
End Sub
Private Sub Command1_Click()
n = ①
s = "政史地物化生技" : temp=""
For i = 1 to n
temp = temp + a( i )
Next i
For i = 1 to len(temp)
m = ②
b(m) = b(m) + 1
Next i
For i = 1 to len(s)
list1.Additem Mid( s, i, 1 ) + ③ + "人"
Next i
End Sub
Function pos(j As Integer ) As Integer '该函数用于查找科目在s中的位置
Dim k as Integer
For k = 1 to len(s)
If Then pos = k : Exit For
Next k
End Function
① ② ③
在列表框List1中显示整理前的数据,单击“排序”按钮,整理结果显示在列表框List2中,程序运行界面如图所示。
Dim a(20) As Integer
Private Sub Form_Load()
Randomize '对随机函数进行随机初始化
For i = 1 To 20
a(i) = ①
List1.AddItem Str(a(i))
Next i
End Sub
Private Sub Cd1_Click()
Dim Done As Boolean
Dim i As Integer, j As Integer, k As Integer, t As Integer
For i = 20 To 1 Step -1
If a(i) Mod 3 = 0 Then Exit For 'Exit For表示跳出For循环
Next i
If i = 0 Then
Label1.Caption = "没有满足条件的数"
Else ‘对能被3整除的数进行排序
②
Do While Not Done
j = i
Done = True
k = j - 1
Do While k >= 1
If a(k) Mod 3 = 0 Then
If a(k) > a(j) Then t = a(k): a(k) = a(j): a(j) = t: Done = False
③
End If
k = k - 1
Loop
Loop
End If
For i = 1 To 20
List2.AddItem Str(a(i))
Next i
End Sub
① ② ③