修改时间:2024-07-31 浏览次数:135 类型:期中考试
Private Sub Command1_Click()
Dim s As String, ch As String
Dim n As Integer, t As Integer, c As Integer
s = "Go-2020-12"
n = Len(s):t = 0
For i = 1 To n
ch = Mid(s,i,1)
If ch >= "0" And ch <= "9" Then
t = t + Val(ch)
Else
c = t: t = 0
End If
Next i
Label1.Caption = Str(c)
End Sub
执行完以上程序段后,标签Label1上显示的内容为( )
Private Sub Command1_Click()
Dim i As Integer
Dim x As Integer
Dim s As String
Randomize
i = 1: s = "1"
Do While i <= 6
x = Int(Rnd * 9) + 1
If x Mod 2 = i Mod 2 Then
s = s + Str(x)
i = i + 1
End If
Loop
Label1.Caption = s
End Sub
运行程序后,标签Label1中可能出现的是( )
从1图b到图c可通过设置图d中(填字母A/B/C/D)得到。
Private Sub check_Click()
Dim s as string, ss as string, s1 as string, s2 as string
Dim i as integer, bz as integer
bz = 0
For i = 1 To Len(s)
ss = Mid(s, i, 1)
If ss = "-" Then
bz = bz + 1
ElseIf bz = 1 Then
s1 = CStr() + s1 ‘Cstr函数是在str的基础上去除前导空格
ElseIf bz = 2 Then
s2 = s2 + ss
End If
Next i
If Then
Label1.Caption = "符合标准"
Else
Label1.Caption = "不符合标准"
End If
End Sub
Private Sub Command1_Click()
Dim i As Integer, j As Integer, n As Integer
Dim zm As Integer, flag As Boolean, zf As string
Randomize ‘重置rnd函数,确保每次产生的随机数不一致
zf = ""
n = Val(Text1.Text)
For i = 1 To n
zm = Int(Rnd * 26 + 65)
For j = 1 To Len(zf) Step 2
If Asc(Mid(zf, j, 1)) = zm Then
flag = True
Exit For
End If
Next j
If flag = False Then zf = zf + Chr(zm) + ","
Next i
Text2.Text = zf
End Sub
Private Sub Command2_Click()
Dim i As Integer, zf As string
zf=Text2.Text
k = 1
For i = 3 To Len(zf) - 1 Step 2
If Mid(zf, k, 1) > Mid(zf, i, 1) Then k = i
Next i
List1.AddItem Mid(zf, k, 1)
Text2.Text =
End Sub
试题篮