s="Hello, Kitty!"
n=Len (s)
Text1. text= Mid (s,7,n-7)
Dim y as Integer, i as integer
y=0
For i=1 To 10 Step 2
y=y+1
Next i
Dim x As Integer,s As String,t As Integer
x=Val(Text1.Text)
Do While x>0
Loop
Label1.Caption= s
方框中的代码由以下三部分组成:
①x=x\2
②s=Str(t)+s
③t=x Mod 2
代码顺序正确的选项是( )
s=“Good Luck 2019!”
n=0:m=0:k=0
For i=1 To Len(s)
ch=Mid(s,i,1)
If ch >=“0”And ch<=“9” Then
m=m+1
Else If ch>=“a” And ch<=“z” Then
n=n+1
Else
k=k+1
End If
Next i
执行该程序段后,变量k的值为( )
图b |
图a |
图b |
实现上述功能的VB程序如下,请回答下列问题。
Const n = 10
Dim a(1 To n) As Integer
Private Sub Command1_Click() '素数迁移模块
Dim i As Integer
List1.Clear '清除列表框
List2.Clear
For i = 1 To n
For j = 2 To a(i) - 1
If Then
Exit For 'Exit For的功能是退出For循环
End If
Next j
If Then
List2.AddItem Str(a(i))
Else
List1.AddItem Str(a(i))
End If
Next i
End Sub
Private Sub Form_Load() '随机数初始化模块
Randomize '随机数种子初始化
For i = 1 To n
a(i) =
List1.AddItem Str(a(i))
Next i
End Sub
小王利用VB程序实现这一加密功能,程序界面和代码如下所示:
Private Sub Com_ jm_ Click()
Dim x As String, ch As String, cl As String
Dim sl As String, s2 As String, s As String
Dim i As Integer, n As Integer, y As Integer
x= Text1. Text
n=Len(x)
For i=1 To n
ch= Mid(x, i, 1)
If ch >= "0" And ch <= "9" Then
①
s2=s2 & y
Elself ch >="a" And ch<="z" Then
y=(Asc(ch)-Asc("a")+3)Mod 26
②
s1=c1+s1
Else
y=(Asc(ch)- Asc("A")+3) Mod 26
c2=Chr(Asc("A")+y)
s1=c2+s1
End If
Next i
③
Text2 Text=s
End sub
① ② ③