本文介绍了Vbscript很少执行函数,有机会使用随机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Vbscript的新功能.我做了一个带有两个参数的随机函数,并称之为它导致无限循环打开无限程序.
New to Vbscript.I made a random function with two parameters.And called itIt resulted in a infinite loop opening infinite program.
Function random(v1,v2)
Randomize
rdm =(Int((v2 - v1 + 1)* Rnd + v1))
End Function
Function download()
Set shell = createobject("wscript.shell"):shell.run "mspaint.exe"
End function
'I want this download function to run rarely
Do
Call random(100,1000)
If rdm>700 And rdm <760 Then
Call download()
End If
loop
推荐答案
为return
值添加了代码,并添加了Exit Do
语句来打破循环.
Added code to return
value and Added Exit Do
statement to break the loop.
希望这会对您有所帮助.
Hope this will help you..
Function random(v1,v2)
Randomize
random=(Int((v2 - v1 + 1)* Rnd + v1))
End Function
Function download()
Set shell = createobject("wscript.shell"):shell.run "mspaint.exe"
download=true
End function
'I want this download function to run rarely
Do
rdm= random(100,1000)
If rdm>700 And rdm <760 Then
Call download()
Exit Do ' this will break the loop if condition is met
End If
loop
这篇关于Vbscript很少执行函数,有机会使用随机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!