VB实验 过程应用程序设计
展开全部
Function Prime(n As Integer) As Boolean
Dim i As Integer
Prime = True
For i = 2 To Sqr(n)
If n / i = n \ i Then Prime = False: Exit For
Next i
MsgBox Prime
End Function
Function Max() As Integer
Dim a(99) As Integer
Dim i%, min%
Randomize
For i = 0 To 99
a(i) = Int(Rnd * 100)
Next
min = a(0)
For i = 0 To UBound(a)
If a(i) < min Then min = a(i)
Next
MsgBox min
End Function
Function Multiply(n As Long) As Long
Dim i As Long
Multiply = 1
For i = 1 To n
Multiply = Multiply * i
Next
MsgBox Multiply
End Function
Function fun4() As Double
Dim a%, b%, c%, d%, i%
Dim n As Double
a = 3: b = 5: c = 7: d = 9: n = 10
fun4 = 0
n = 0
For i = 0 To a
n = n + a ^ i
Next
fun4 = fun4 + a / n
n = 0
For i = 0 To b
n = n + b ^ i
Next
fun4 = fun4 + b / n
n = 0
For i = 0 To c
n = n + c ^ i
Next
fun4 = fun4 + c / n
n = 0
For i = 0 To d
n = n + d ^ i
Next
fun4 = fun4 + d / n
MsgBox fun4
End Function
Function SReplace(s As String, s1 As String, s2 As String) As String
Do While InStr(s, s1) > 0
s = Replace(s, s1, s2)
Loop
MsgBox s
End Function
Dim i As Integer
Prime = True
For i = 2 To Sqr(n)
If n / i = n \ i Then Prime = False: Exit For
Next i
MsgBox Prime
End Function
Function Max() As Integer
Dim a(99) As Integer
Dim i%, min%
Randomize
For i = 0 To 99
a(i) = Int(Rnd * 100)
Next
min = a(0)
For i = 0 To UBound(a)
If a(i) < min Then min = a(i)
Next
MsgBox min
End Function
Function Multiply(n As Long) As Long
Dim i As Long
Multiply = 1
For i = 1 To n
Multiply = Multiply * i
Next
MsgBox Multiply
End Function
Function fun4() As Double
Dim a%, b%, c%, d%, i%
Dim n As Double
a = 3: b = 5: c = 7: d = 9: n = 10
fun4 = 0
n = 0
For i = 0 To a
n = n + a ^ i
Next
fun4 = fun4 + a / n
n = 0
For i = 0 To b
n = n + b ^ i
Next
fun4 = fun4 + b / n
n = 0
For i = 0 To c
n = n + c ^ i
Next
fun4 = fun4 + c / n
n = 0
For i = 0 To d
n = n + d ^ i
Next
fun4 = fun4 + d / n
MsgBox fun4
End Function
Function SReplace(s As String, s1 As String, s2 As String) As String
Do While InStr(s, s1) > 0
s = Replace(s, s1, s2)
Loop
MsgBox s
End Function
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询