单击“计算”按钮Command1后,则在文本框Text2中显示的内容是,在文本框Text3中显示的内容是。
Private Sub Command1Click()
Dim s As Integer, t As Integer, n As Integer
n = Val(Text1.Text)
t = 0
s = 0
For i = 1 To n
If Int(Sqr(i)) = Sqr(i) Then
s = s + i
t = t + 1
End If
Next i
Text2.Text = Str(t)
Text3.Text = Str(s)
End Sub
代码如下:
Private Sub Command1_Click()
Dim a(1 To 13) As Integer, i As Integer, j As Integer, n As Integer
For i=1 To 13
a(i)=0
Next i
i=1:n=0:j=1
Do While i<=13
Do While True
If j>13 Then
If a(j)=0 Then n=n+1
If n=i Then
n=0
Exit Do
End If
j=j+1
Loop
Loop
Label1.Caption="原来牌的顺序是:"
For k=1 To 13
Label2.Caption =
End Sub
数组dzb_h的16个元素分别存放16进制数的16个基本数码。
依次取出原始颜色代码中每一位对应的16进制数码,例如原始颜色代码为#123456,第1次取出1,第2次取出2……
在数组dzb_h各元素中找到对应16进制数码的元素
运用规律:0+F=1+E…=7+8取得反相色并累加,例如:数组dzb_h第1个元素值的反相色的值是数组dzb_h第16个元素值。
输出得到的反相色。
实现上述功能的VB程序代码段如下,请完善相关程序代码。
Private Sub fx_cmd_Click()
Dim dzb_h(1 To 16) As String
Dim o_c As String, f_c As String, i As Integer, xbxh As Integer, c As String
dzb_h(1)="0":dzb_h(2)="1":dzb_h(3)="2":dzb_h(4)="3":dzb_h(5)="4":dzb_h(6)="5":dzb_h(7)="6"
dzb_h(8)="7":dzb_h(9)="8":dzb_h(10)="9":dzb_h(11)="A":dzb_h(12)="B":dzb_h(13)="C"
dzb_h(14)="D":dzb_h(15)="E":dzb_h(16)="F"
o_c=o_c_txt.Text
f_c="#"
Do While i<=Len(o_c)
c=Mid(o_c,i,1)
If Asc(c)>96 Then
xbxh=1
Do While xbxh<17
If Then
f_c=
Exit Do
End If
xbxh=xbxh+1
Loop
i=i+1
Loop
f_c_lab.Caption=f_c
End Sub
a(1) = 23: a(2) = 32: a(3) = 46: a(4) = 38: a(5) = 15: a(6) = 55: a(7) = 39
For i = 1 To 5
For j = 2 To 7-i
If a(j) > a(j + 1) Then
t = a(j): a(j) = a(j + 1): a(j + 1) = t
c = c + 1
End If
Next j
Next i
c 的初值是0,程序执行完后,c的值是( )
s=1
For i=1 To 20
If i Mod 5=0 Then
s=s+i
End If
Next i
n=20:s=""
Do While n<>0
r=n Mod 2
s=Str(r)+s
n=n\2
Loop
Label1.Caption=s
该程序段运行后,标签Label1上显示的内容是( )
s = "python2021": t = "": i = 1
Do While i < Len(s)
c = Mid(s, i, 1): d = Mid(s, i + 1, 1)
If c < d Then t = t + c Else t = t + d
i = i + 2
Loop
Label1.Caption = t
执行该程序段后,标签Label1上显示的内容是( )
Do While条件
循环体
Loop
s = Text1. text
i=1: max1=1: maxi=i
j=2
Do While j <= Len(s)
If Then
If j-i> max1 Then max1 =j-i: maxi = i
End If
Loop
If j- i> max1 Then max1=j-i: maxi= i
If max1>1 Then Text2. Text = Mid(s, maxi, max1)
上述程序段中方框处可选语句为( )
①j=j+1
②i = j
③Mid(s, j, 1)>= Mid(s, j - 1, 1)
④Mid(s, j, 1) <= Mid(s, j - 1, 1)
则(1)、(2)、(3)处语句依次为
题目:设计100以内的数中能同时被3或5整除的个数。
小李编写了如下程序求解10个人的出列顺序。程序运行界面如图15-1所示,点击求解按钮后,在Text1中输出出列顺序,在Text2中显示随机数据的值。
Private Sub Command1 _Click( )
Dim ld(1 To 10) As Boolean, i As Integer, j As Integer
Dim rs As Integer, C As Integer, m As Integer
Randomize
For i=1 To 10
ld(i) = True ‘数组元素为True表示第i人当前在队列中
Next i
c=0:rs=10
m =Int(Rnd*3)*2+3
Do While rs <> 0
If ld(i) = True Then
If c=m Then
ld(i) = False
Text1.Text = Text1.Text + Str(i)
c=0
End If
End If
i =i-1
If Then i=10
Loop
End Sub
k = 0
For i = 1 To 10
If b(a(i)) = 0 Then k = k + 1
b(a(i)) = b(a(i)) + 1
Next i
For i = 1 To k
p = 1
For j = 2 To 10
If b(j) > b(p) Then p = j
Next j
b(p) = 0
s = s + Str(p)
Next i
数组a(1)~a(10)的元素分别为2,5,3,8,8,5,8,9,5,3。数组b(1)~b(10)的元素初始值均为0,执行程序后,变量s的值为( )
X=5
For i = 1 TO 20 STEP 2
x=x+i^2
Next i
Din i As Integer, j As Integer
For i=1 To 5
For j=1 To 5-i
Print ""; '输出一个空格
Next j
For j=1 To i
Print **;
Next j
Next i