只能做一个数字而不是0到2之间的数字多次 [英] Only making one number instead of a number between 0 and 2 multiple times

查看:91
本文介绍了只能做一个数字而不是0到2之间的数字多次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好,所以我要编写一个简洁的程序,使您的数字锁,大写锁和滚动锁键闪烁.我的问题是,当我运行它时,它只会产生一个数字,而不是多个不同的数字,那么关于问题可能是什么的任何想法?

Ok, so I was going to make a neat program that made your Number Lock, Caps Lock, and Scroll Lock keys flash. My problem is when I run it, it only produces one number, instead of multiple ones that are different, any ideas as to what the problem might be?

Set Keys = WScript.CreateObject("WScript.Shell") 'So The Script Can Press keys
Dim MAX, MIN 'Declaration
MAX = 2 'Sets MAX Equal To 2
MIN = 0 'Sets MIN Equal To 0
Randomize 'So The Numbers Are Different All The Time

Number = (Int((MAX-MIN+1)*Rnd+MIN)) 'Assigns The Random number To A Variable
Do Until X = 10 'Does The Loop 10 Times
Select Case Number
    Case 0 'If Number = 0 Then The Following happens
        WScript.Sleep 500 'Stops The Script For 500 Milliseconds
        Keys.SendKeys("{NUMLOCK}") 'Pushes The Number Lock
    Case 1 'If Number = 1Then The Following happens
        WScript.Sleep 500 'Stops The Script For 500 Milliseconds
        Keys.SendKeys("{CAPSLOCK}") 'Pushes The Caps Lock
    Case 2 'If Number = 2 Then The Following happens
        WScript.Sleep 500 'Stops The Script For 500 Milliseconds
        Keys.SendKeys("{SCROLLLOCK}") 'Pushes The Scroll Lock
End Select
X = X + 1 'Increment
Loop

推荐答案

发表评论作为答案...

Posting comment as answer...

好吧,对于初学者,您可能希望将方程式放入循环中,以便在每次循环后重新生成随机数.

Well, for starters, you might want to put your equation within the loop so it regenerates the random number after every loop.

这篇关于只能做一个数字而不是0到2之间的数字多次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆