制作一个vbs小程序(代码)

2024-11-18 00:42:10
推荐回答(2个)
回答1:

请看我的终极代码:

On Error Resume Next
Dim num,var,writer,won,h
'Dim
h=Chr(13)
writer="▉◎◎控盘惨制作◎◎▉ - "
'Variables.
Do
Randomize()
num=Int(Rnd()*100)
var=MsgBox("我等一下会给出一个数字哦~你猜猜它是不是大于50呢?"+h+h+"▲注意:如要退出程序请点击""取消""或右上角的""X""按钮",3+64,writer+"请猜数大于50还是小于50")
Select Case var
Case 6
'\\\\\\\\
if num>50 Then
won=0
else
if num=50 Then
won=1
else
won=2
End if
End if
'\\\\\\\\
Case 7
'\\\\\\\\
if num<50 Then
won=0
else
if num=50 Then
won=1
else
won=2
End if
End if
'\\\\\\\\
Case Else
Wscript.Quit
End Select
Select Case won
Case 0
MsgBox "恭喜你,你赢了!"+h+h+"⊙数字=" & num,0+64,writer+"Information"
Case 1
MsgBox "呵呵,平局,再来~"+h+h+"⊙数字=" & num,0+64,writer+"Information"
Case 2
MsgBox "你选错了哦,别气馁"+h+h+"⊙数字=" & num,0+64,writer+"Information"
End Select
Loop

我的代码考虑到了随机数可能等于50,并且制作了相关处理.并且随机数范围是100,这样的随机数几率才各占50%. 比那个什么lurong777的先进10000倍!!!

回答2:

亲,代码如下哦:
Dim WshShell,BtnCode
Set WshShell=WScript.CreateObject("WScript.Shell")
Randomize()
Num=Int(99*Rnd())
BtnCode=WshShell.Popup("请猜数大于50",,"请选择",4+32)
Select Case BtnCode
Case 6 If Num>50 Then MsgBox "恭喜你,你赢了!" Else msgbox "你选错了哦,别气馁!数字为:" & Num
Case 7 If Num<50 Then MsgBox "恭喜你,你赢了!" Else msgbox "你选错了哦,别气馁!数字为:" & Num
End Select