
Private Sub Command1_Click() ‘不停除2到商为0为止,所得余数倒推
Dim sjzs As Integer ‘sjzs:十进制数
Dim rjzs As String ‘rjzs:二进制数
sjzs = Val(Text1.Text)
rjzs = ""
Do While
rjzs = Str(sjzs Mod 2) + rjzs
Label3.Caption = rjzs
End Sub

Private Sub Command1_Click()
Dim a(1 To 10) As Integer
Dim s As Integer
Dim max As Integer
n = Val(Text1.Text)
i = 1
Do While i <= n
a(i) = Int(Rnd * 100)
List1.AddItem Str(a(i))
s = s + a(i)
①
Loop
max = a(1)
For i = 2 To n
If a(i) > max Then ②
Next i
List1.AddItem "和为:" + ③
List1.AddItem "最大值为:" + Str(max)
End Sub
供①②选填:A.n=n+1 B. i=i+1 C.max=a(i) D.a(i)=max
①应选;②应选
空格③处应填写的代码为:。


Private Sub Command1_Click()
Dim dx As String, dw As String
Dim s As String, c As String
Dim ch As String
Dim i As Integer
dx = "零壹贰叁肆伍陆柒捌玖拾"
dw = "亿仟佰拾萬仟佰拾元"
s = Text1.Text
If Len(s) > 9
Text2.Text = "输入的数据超出所能转换的范围"
Else
For i = 1 To Len(s)
ch =
c = c + Mid(dx, Val(ch) + 1, 1) + Mid(dw, 9 - Len(s) + i, 1)
Next i
Text2.Text = c + "整"
End If
End Sub
PRIVATE SUB COMBO1 (KEYASCII AS INTEGER)
IF
END IF
END SUB
程序界面如图所示,左边列表框List1中显示的是部分职工的卡号和余额,在文本框Text1中输入职工的IC卡号,单击“查询余额”按钮(Command1)后,如果找到此卡号,则在标签Lab3中显示“此卡号余额为”和对应的余额值,如果未找到则显示“找不到此卡号,请重新输入”。
解决此问题的部分程序段如下:
Const n=500' 设卡号总数为500
Dim zg(1 To n) As Long
Dim ye(1 To n) As Single
Private Sub Form1_Load()
' 此过程用于对数组zg和数组ye进行初始赋值,代码略
End Sub
Private Sub Command1_Click()
Dim x As Long, i As Long, j As Long, m As Long, find As Boolean
x=Val(Text1.Text)
i = 1 : j = n : find = False
Do While ‘改错
m = Int((i + j) / 2
If x = zg(m) Then
①
Else If ② Then
j = m - 1
Else
i = m + 1
End If
Loop
If find = true Then
Lab3.Caption=″此卡号余额为″+Str(ye(m))+″元″
Else
Lab3.Caption=″找不到此卡号,请重新输入″
End If
End Sub
程序中①画线处应填入。
程序中②画线处应填入。

Private Sub Command1_Click()
Dim t1 As Integer, t2 As Integer
Dim i As Integer, t As Integer
Dim f As Single
List1.Clear
t1 = Val(Text1.Text)
t2 = Val(Text2.Text)
If Then '(选填字母,从下列A、B、C、D四个选项中选取一项)
t = t1: t1 = t2: t2 = t
End If
i = t1
Do While '(选填字母,从下列A、B、C、D四个选项中选取一项)
f = i * 9 / 5 + 32 '摄氏温度转换为华氏温度
List1.AddItem Str(i) + " " + Str(f)
'(填程序代码)
Loop
End Sub
划线①、②处的选项:
A .i <= t2 B .f <= t2 C .t1 > t2 D . i < f
请回答下面问题:
Private Sub Command1_Click()
Dim n,i,j,k,x,L,R,c As Integer
Dim goods(1 To 20)As String 'goods(i)存储商品的名称
Dim price(1To 20)As Integer 'price(i)存储商品的价格
Dim s,ch As String
s=Text1.Text:x=Val(Text2. Text)
j=1:k=0
For i=1 To Len(s)
ch=Mid(s,i,1)
If ch="," Then
k=k+1
If k Mod 2=1 Then
Else
price(k\2)=Val(Mid(s,j,i-j))
End If
j=i+1
End If
Next i
n=k\2
For i=1 To n-1
For i=1 To n-i
If price(j)>price(j+1)Then
k=price(j):price(j)=price(j+1):price(j+1)=k
End If
Next j
Next i
For i=2 To n
L=i:R=n
Do While L<=R
m=(L+R)\2
If price(m)+price(k)=x Then
c=c+1
List1. Addltem goods(k)& Str(price(k))&"元 和" & goods(m)& Str(price(m))& "元"
j=m
Do While price(j)=price(j-1)
j=j-1
c=c+1
Listl. Addltem goods(k)& Str(price(k))& "元 和" & goods(j)& Str(price(j))& "元"
Loop
Do While
m=m+1
c=c+1
List1. Addltem goods(k)& Str(price(k))& "元 和" & goods(m)& Str(price(m))& "元"
Loop
Exit Do ‘Exit Do 表示退出Do循环
Elself price(m)+price(k)>x Then
R=m-1
Else
L=m+1
End If
Loop
Next i
List1. Addltem"共有:" & Str(c)& "种组合"
End Sub
移红包规则:
①编号为1的堆上的红包,只能移到编号为2的堆上;
②编号为n的堆上的红包,只能移到编号为n-1的堆上;
③其它堆上的红包,可以移到相邻左边或右边的堆上。
现要求找出最少的移动次数使每堆的红包数-样多。如图所示,在文本框Text1中输入红包堆数n,在文本框Text2中依次输入每堆红包的红包个数(以“,”为分隔符和结束符),单击“移红包次数统计”按钮Command1后,在标签Labe13中显示最少的移动次数。

Const Sum = 40 ‘红包总个数
Private Sub Command1_Click()
Dim n As Integer ‘红包的堆数
Dim s As String, k As Integer
Dim avg As Integer '最终每堆的红包个数
Dim ml As Integer, m2 As Integer
Dim tmp As Integer, count As Integer, ans As Integer
n=
s = Text2. Text
avg=Sum/n
tmp=0:count=0:ans=0
For k=1 To Len(s)
c = Mid(s, k, 1)
If c <>”,”Then
tmp =
Else
count = count + 1
If count = 1 Then
m1 =tmp
Else
m2 = tmp
If m1 <> avg Then
m2=m2-(avg-m1)
ans=ans+1
End If
End If
tmp=0
End If
Next k
Labe13. Caption = Str (ans)
End Sub
Private Sub Command1_Click( )
Dim s1, s2, result, t As String
Dim span, jw As Integer
s1=Text1. Text:s2=Text2. Text
span=Len(s1)-Len(s2)
If span<0 Then
t=s1:s1=s2:s2=t
span= ①
End If
For i=1 To span
s2="0"+s2
Next i
jw=0:result=" "
For i= ② To 1 Step-1
x=Val(Mid(s1, I, 1))+Val(Mid(s2,i,1))+jw
jw=x\2
result=Str(x Mod 2)+result
Next i
If jw=1 Then result="1"+result
Text3. Text=result
End Sub
Private Sub Comd1_Click()
Dim i As Integer, j As Integer, n As Integer
Dim ch As String, s As String, ss As String
s = Text1.Text
n = 0: ss = ""
i = 1
Do While i <= Len(s)
If ch >= "0" And ch <= "9" Then
Else
For j = 1 To n
ss = ss + ch
Next j
n = 0
End If
Loop
Text2.Text = ss
End Sub
Private Sub Commandl_Click( )
Dim s As Integer, cz As Integer 'cz存储超重克数
Dim k As Integer
'依次从1~5号瓶中取出1、2、4、8、16粒药,并计算总重量,存储在变量s中,代码略
cz=s-310
Text1.Text= ①
k=0
Do While cz<>0
k=k+1
If ② Then List 1.Addltem"第"+Str(k)+"瓶"
cz=cz\2
Loop
End Sub
① ②
Dim a As Integer
Private Sub Command1_Click()
Timer1.Enabled = True
![]()
End Sub
Private Sub Timer1_Timer()
a = a + 1
Image1.Picture = LoadPicture(App.Path & "\" & a & ".jpg")
If a >= 8 Then a = 0
End Sub
单击命令按钮Command1,加框处语句执行的时间间隔为( )
Option Explicit
Dim n
Private Sub Command1_Click()
N=0
Timer1.=1000
Timer1.Enabled=
End Sub
Private Sub Commend2 Click()
Timer1.Enabled =
End Sub
Private Sub Command3_Click()
Me
End Sub
Private Sub Form_Load()
Timer1.Enabled =
Text1.Text =0
Text1.Locked=True
End Sub
Private Sub Timer1_Timer()
N=n+1
Text1.Text =
End Sub