VB编程的题,达人进一下
发布网友
发布时间:2024-10-04 19:17
我来回答
共2个回答
热心网友
时间:2024-10-04 21:01
1:首先,在窗体上新建一个按钮叫CmdEven,然后写入代码
sub CmdEven_Click()
dim i
dim sum
sum = 0
for i=2 to 100 step 2
sum = sum + i
next i
print sum
end sub
2:建立一个按钮,叫CmdOK,建立一个文本框,叫Text1,程序如下
sub CmdOK_Click()
dim n
n=val(Text1.text)
print jie(n)
end sub
function jie(dim n as integer)
if n<=1 then
jie = 1
else
jie = jie(n-1)
end if
end function
热心网友
时间:2024-10-04 21:02
'偶数输出
Dim i, t As Integer, h As Long
Print "以下是2-100之间的偶数:"
For i = 2 To 100 Step 2
t = t + 1
If t = 10 Then t = 0: Print
Print i & " ";
h = h + i
Next
Print "2 - 100之间所有的偶数和为: " & h
'阶乘输出
Dim i, t As Integer, j As Long
i = Val(InputBox("请输入一个数"))
If i <= 0 Then Exit Sub
j = 1
For t = 1 To i
j = j * t
Next
Print "阶乘积为: " & j
闲麻烦的话加我QQ 我做给你
57741236