求vb小程序代码
1.输出任意十个数中最大的数.2.输出任意n个数中大于零的个数,偶数的个数,奇数的个数.
3.求p的值。p=1!+3!+5!+7!+9!
4.输出1到100自然数中被7整除的数据的个数及它们的和.
追问:来自手机问问我想要完整的程序代码
追问:来自手机问问我想要完整的程序代码
答案:Private Sub Command1_Click() '1
Dim a(1 To 10)
Dim max
For i = 1 To 10
Randomize
a(i) = Int(Rnd * 100)
Print a(i);
Next i
For i = 2 To 10
If max < a(i) Then max = a(i)
Next i
Print "Max"; max
End SubPrivate Sub Command2_Click() '2
Dim a()
Dim num, js, os, n
n = Int(Val(InputBox("n=")))
ReDim a(1 To n)
For i = 1 To n
Randomize
a(i) = Int(Rnd * 1000 - 500)
Print a(i);
If n Mod 10 = 0 Then Print
If a(i) > 0 Then num = num + 1
If a(i) Mod 2 = 0 Then
os = os + 1
Else
js = js + 1
End If
Next iPrint "大于零的数有"; num, "个"
Print "奇数有"; js, "个"
Print "偶数有"; os, "个"
End SubPrivate Sub Command3_Click() '3
Dim p
For i = 1 To 9 Step 2
Dim js
js = 1
For j = 1 To i
js = js * j
Next j
p = p + js
Next i
Print p
End SubPrivate Sub Command4_Click() '4
Dim sum, n
For i = 1 To 100
If i Mod 7 = 0 Then
Print i;
n = n + 1
sum = sum + i
If n Mod 8 = 0 Then Print
End If
Next i
Print "他们的和为"; sum
End Sub第一题: privatesubcommand1_click() dimaasstring a="ASDFGHJKL" printstrreverse(a) endsub 第二题:1
程序是将十进制的20转化为2进制数字
第三题:
求出242和44的最大公约数以及最小公倍数
输出的结果中,x代表最大公约数,z/x代表最小公倍数 privatesubcommand1_click() dimaasstring a=inputbox("请输入一个字符串")
print"原来的字符串是:"
dim n,i,a(10)
n=a(1)
for i= 1 to 10
if a(i)>n then n=a(1)
next
print n
上一个:VB中sendmessage具体用法
下一个:如何能用VB制作病毒?