Private Sub Command1_Click()
n = 6
x = 1
For i =1 To n
x = x * i
Next
End Sub( )
Private Sub Command1_Click()
Dim x As Integer, y As Integer
Dim i As Integer, j As Integer
x=val(text1.text)
i=x \ 10
_____________ ①
y=j*10+i
Text1.Text = y ②
End Sub
实现上述功能的VB程序如下,但加框处代码有错,请改正。
Private Sub Command1_Click()
Text2.Text=coding(Text1.Text)
End Sub
Private Function coding(s As String)As String
Dim n As Integer,i As Integer,C As String
c=Mid(s,1,1)
n=1
For i=2 To Len(s)
If Then ‘(1)
n=n+1
Else
c=c+Str(n)+“/”
n=1
End If
Next i
coding= ‘(2)
End Function
1图
2图
Private Sub Command1_Click()
Dim x1 As Integer, x2 As Integer, n As Integer
Dim sum As Long
x1 = Val(Text1.Text)
x2 = Val(Text2.Text)
Sum = 0
If x1 < x2 Then n = 1 Else
For i = x1 To x2 Step n
If Then
Sum = Sum + i
Next i
Label3.Caption = "从" & x1 & "到" & x2 & "之间所有奇数的累加和=" & Str(Sum)
End Sub
a = 3
b = 4
c = 5
If a > b Then a = b Else b = a
则程序运行后的a和b的值分别是:( )
Dim x As Integer, y As Integer, s As Integer
x=3:y=4
If x<y And y<0 Then
s=x Mod y
ElseIf y>0 and y<x Then
s=x*y
ElseIf x=0 Or y=0 Then
s=x+y
Else
s=0
End If
该程序段运行之后,变量s的值为( )
Private Sub Cmd1_Click()
Dim c As Integer, year As Integer
c=0
If Then
c=c+1
EndIf
Next year
Label1.Caption="闰年共有"+Str(c)+"次"
EndSub
Private sub command1_click()
Dim a(0 to 9) as integer ‘数组元素a(i)中存放数字i的个数
Dim s as string , ch as string
Dim t as integer
For i=0 to 9
a(i)=0
next i
s=text1.text
for i=1 to len(s)
if ch>=”0”and ch<=”9” then
t=
a(t)= a(t)+1
end if
next i
list1.clear
for i=1 to 9
if a(i)<>0 then
list1.additem ”数字:”+str(i)+ ”,共有”+ str(a(i))+ ”个”
end if
next i
end sub
请回答下列问题:
Private Sub Command1_Click()
Dim s As String, sum As Integer
Dim i As Integer, j As Integer
①
sum = 0
j = 0
For i = 1 To Len(s)
ch = Mid(s, i, 1)
If ch >= "0" And ch <= "9" Then
j = ②
Else
sum = sum + Val(Mid(s, i - j, j))
j = 0
End If
Next i
Label1.Caption = "数字之和为:" + Str(sum) End Sub
① ②
For i = 2 To 10
Print "*"
Next i
Dim a as Integer
Dim b as Integer
Dim c as Integer
a = 1
b = 1
For i = 1 To 4
c = a+b
a = b
b = c
Next i
Print c
运行结果是:
n=int(input(“请输入数字:”))
if n>5 :
print(4*n)
else :
print(7*n)
如果输入5,则程序运行的结果为( )
s=0
for i in range(1,6,2):
s=s+i
print(s)
i = 1: j = 10
x = Int(Rnd * 50) * 2 + 1
Do While i <= j
m = (i + j) \ 2
If x = f(m) Then Exit Do
If x < f(m) Then
j = m - 1
Else
i = m + 1
s = s + Str(m)
Loop
数组元素f(1)到f(10)的值依次为:3,6,9,11,18,20,25,39,76,98,该程序运行后,s的值不可能的是( )
n = Len(s)
For i = 1 To n \ 2
If Mid(s, i, 1) > Mid(s, n - i + 1, 1) Then s1 = s1 + Mid(s, i, 1)
Else
s1 = Mid(s, n - i + 1, 1) + s1
End If
Next i
Text1.Text = s1
执行该程序后,在文本框Text1中显示的是 ( )
Private Sub Command1_ Click ()
Dim i As Integer
For i=1 To 10
If Not i Mod 2=0 or i Mod 5=0 Then
Print i
Next i
End Sub
Private Sub Command1_Click()
Dim d As Single, g As Single, s As Single ‘定义程序中使用的变量
d = Val(Text1. Text) ‘在Text1中输入三角形的底
g = Val(Text2. Text) ‘在Text2中输入三角形的高
s = d×g÷2 ‘计算三角形面积
Text3. Text = s ‘在Text3中显示面积值
End Sub
请回答下列问题:
Dim a(1 To 64) As Integer
Dim b(0 to 1) As String
Private Sub Form_Load()
b(0) = " " : b(1) = " *"
'给数组a赋初值,并在列表框List1显示箭头图形,代码略
End Sub
Private Sub up_Click()
Dim i As Integer, j As Integer, s As String, tmp As Integer
List1.Clear
For i = 1 To 8 '将第i列数据向上平移一个位置
tmp =
For j = 2 To 8
a((j - 2) * 8 + i) = a( )
Next j
a(7* 8 + i) = tmp
Next i
s = ""
For i = 1 To 64
If i Mod 8 = 0 Then List1.AddItem s : s = ""
Next i
End Sub
Private Sub turn_Click()
'调转箭头方向(朝上的变为朝下,朝下的变为朝上),代码略
End Sub
Private Sub down_Click()
'图形向下移动一个位置,代码略
End Sub
小明在代码中插入了语句“df_delc=df.drop(0)”, 其余不做修改,那么运行这段修改后的代码,其运行结果为( )