永发信息网

求VB程序设计实例整体

答案:1  悬赏:80  手机版
解决时间 2021-03-17 20:12
  • 提问者网友:留有余香
  • 2021-03-17 11:39
求VB程序设计实例整体
最佳答案
  • 五星知识达人网友:佘樂
  • 2021-03-17 12:04



Option Explicit
Option Base 1
Dim C() As Integer
Dim D() As Integer
Private Sub Command1_Click()
Randomize
Dim i As Integer, J As Integer, K As Integer, l As Integer, h As Integer
Dim P As Integer, Q As Integer, N As Integer
J = 1
K = 1
l = 1
Dim a(80) As Integer
Dim B() As Integer

For i = 1 To 80
a(i) = Int(Rnd * 90 + 10)
Print a(i);
If i Mod 10 = 0 Then Print
If fun1(a(i)) = True Then
ReDim Preserve B(J)
B(J) = a(i)
J = J + 1
End If
If a(i) Mod 2 = 0 Then
ReDim Preserve C(K)
C(K) = a(i)
K = K + 1
Else
ReDim Preserve D(l)
D(l) = a(i)
l = l + 1
End If
Next i
Print

N = UBound(C())

For J = 1 To N
For i = 1 To N - J
P = C(i)
Q = C(i + 1)
If P > Q Then C(i) = Q: C(i + 1) = P
Next i
Next J

N = UBound(D())
For J = 1 To N
For i = 1 To N - J
P = D(i)
Q = D(i + 1)
If P < Q Then D(i) = Q: D(i + 1) = P
Next i
Next J
Print

For i = 1 To UBound(C)
Print C(i);

If i Mod 10 = 0 Then Print
Next i
Print
Print

For i = 1 To UBound(D)
Print D(i);

If i Mod 10 = 0 Then Print
Next i

Print

Print " 素数个数为" & Val(UBound(B))
For i = 1 To UBound(B)
Print B(i);
h = h + B(i)
If i Mod 10 = 0 Then Print
Next i

Print
Print "素数的和为" & h
Print

End Sub

Private Sub Command2_Click()
End
End Sub
Private Function fun1(a As Integer) As Boolean
Dim i As Integer
fun1 = True
For i = 2 To Sqr(a)
If a / i = Int(a / i) Then fun1 = False: Exit For
Next i
End Function

Private Sub Command3_Click()
Form1.Cls
End Sub
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯