i = 1
Do While i <= 5
If i = 0 or a(i - 1) <= a(i) Then
i = i + 1
Else
t = a(i): a(i) = a(i - 1): a(i - 1) = t
i = i - 1
End If
Loop
For i = 1 To 5
List2.AddItem a(i)
Next i
数组元素a(0)到a(5)的值依次为“0,71,22,48,79,27”,经过该程序段“加工”后,数组元素a(4)的值为( )
s = Text1.Text
For i = 1 To Len(s)
ch = Mid(s, i, 1)
nk = Asc(ch) - i
If nk < 0 Then nk = nk + 127
Text2.Text = Text2.Text + Chr(nk)
Next i
已知大写字母A的ASCII码值为65,小写字母a的ASCII码值为97,在文本框Text1中输入内容“yhT5”,执行程序段后,文本框Text2显示的内容为( )
Private Sub Command1_Click()
Dim s As String, c As String, i As String, a As String, t As Integer
Randomize
s = “”
For i = 1 To 10
If a <= 26 Then
t = a + 64
Else
End If
c = Chr(t)
s = s + c
Next i
List1.AddItem s
End Sub
以上横线处的正确语句是( )
图b
图c
图b
实现上述功能的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
Dim m2 As String
Private Sub Command1_Click()
Dim flag(1 To 26) As Boolean
Dim num As Integer,t As Integer
Randomize
num = 1
Text3.Text = “”
For i = 1 To 26
flag(i) = False
Next i
Do While num <= 26
x = Int(Rnd * 26) + 97
If flag(t) = False Then
m2 = m2 + Chr(x)
num = num + 1
End If
Loop
Text3.Text = m2
End Sub
Private Sub Command2_Click()
Dim s As String, m As String, result As String
Dim k As String, c As Integer
s = Text1.Text
m = “abcdefghijklmnopqrstuvwxyz”
For i = 1 To Len(s)
k = Mid(s, i, 1)
If k >= ”A” And k <= “Z” Then
k = Chr(Asc(k) + 32)
End If
c = 1: continue = True
Do While
If k = Mid(m, c, 1) Then
continue = False
End If
c = c + 1
Loop
Next i
Text2.Text = result
End Sub