修改时间:2024-07-13 浏览次数:210 类型:期末考试
s = Text1.Text : sum = 0
c = 1 : j = 0
For i = 1 to len(s)
ch = Mid(s, i, 1)
If ch >= "0" And ch <= "9" Then
j = j + 1
Else
If c mod 2 = 1 then sum = sum + Val(Mid(s,i-j,j))
j=0 : c = c + 1
End If
Next i
Label1.Caption = Str(sum)
在文本框Text1中输入“20a20b1c29d9”,执行该段代码后,标签Label1中的结果是( )
图a
图b
图c
图d
Private Sub Command1_Click()
Dim x As Integer, m as double, n As Integer
Dim num1 as Long, num2 as Long
Dim s As String, flag as Boolean, i as Integer
x = val(Text1.Text)
m = x ^ 2
s = Trim(Str(m)) ‘Trim函数去除字符串首尾空格
n = len(s)
For i = 1 to n
num1 =
num2 = Val(Mid(s,i+1,n-i))
If Then
Flag = True
Exit For
End If
Next i
If flag Then
Label2.Caption=Str(x)+ "=" +Str(num1)+ "+" + mid(s,i+1)+ ",是卡布列克数!"
Else
Label2.Caption = Str(x) + "不是卡布列克数!"
End If
End Sub
Private Sub Command1_Click()
Dim p As String, k As String, i As Integer
Dim result As String
result = ""
p = Text1.Text
k = Text2.Text
i = 1
Do While i <= Len(p) - Len(k) + 1
If Mid(p, i, Len(k)) <> k Then
i = i + 1
Else
End If
Loop
Text3.Text =
End Sub
Private Sub Command1_Click()
Dim n As Integer, m As Integer, i As Integer
Dim s As String
n = val(Text1.Text)
m = Int(Rnd * 2)
s = ""
List1.Clear
For i =1 to n * n
m = 1 - m
If Then
List1.Additem s
s = ""
If n mod 2 = 0 then
End If
Next i
End Sub
试题篮