我遇到以下VBS代码时出现问题.它有时只能工作,即使这样它也很快失败.为什么?
Dim Butt
Set Butt = CreateObject("InternetExplorer.application")
Butt.visible = True
Butt2 = InputBox("Put the link to one hat you would like to snipe.", "Hat Selection")
Butt3 = InputBox("Enter the maximum amount of Robux you will spend on this hat.", "Maximum Payment")
Dim Proace
Set Proace = CreateObject("Microsoft.XMLHTTP")
Proace.Open "GET", "http://www.roblox.com", False
Proace.Send
Do
Do While Butt.Busy
WScript.sleep 200
Loop
St00f = CInt(Replace(Mid(St00f, (InStr(St00f, ">R$")+3), 8), "</b>", ""))
If St00f <= CInt(Butt3) Then
Butt.Navigate "javascript:WebForm_DoPostBackWithOptions(new%20WebForm_PostBackOptions(""ctl00$cphRoblox$TabbedInfo$UserSalesTab$lstItemsForResale$ctrl0$lnkBuyNow"",%20"""",%20true,%20"""",%20"""",%20false,%20true))"
Exit Do
End If
Loop
Do While Butt.Busy
WScript.sleep 200
Loop
MsgBox("Congratulations! Your snipe was successful! You sniped "&Butt2&" for "&Butt3&" Robux!")
Butt.Quit
Set Butt = Nothing
Set Proace = Nothing
WScript.Quit
Run Code Online (Sandbox Code Playgroud)
错误:
Script: C:\Users\John\Downloads\SingleHatSniper.vbs
Line: 14
Char: 1
Error: Type mismatch: 'CInt'
Code: 800A000D
Source: Microsoft VBScript runtime error
Run Code Online (Sandbox Code Playgroud)
请帮助我,我对VBS不太好.很明显,我的朋友帮我写了这个.
正如您现在所知,这是发生错误的地方
St00f = CInt(Replace(Mid(St00f, (InStr(St00f, ">R$")+3), 8), "</b>", ""))
Run Code Online (Sandbox Code Playgroud)
这条线做了这些事情
InStr 返回第一次出现的"> R $"的数字位置"R$"Mid将St00f带有start index 的字符串拆分"R$"为长度为8Replace获取拆分字符串并替换"</b>"with 的出现""CInt将字符串转换为整数或更正确*将任何数字转换为子类型Integer*的变体而你在CInt转换时遇到错误.
如果我在你的位置,我将逐行分割,每行只保留一个函数,然后在每行之后尝试使用MsgBox作为输出,并找出它的错误.
关键是变量St00f和变量的含义.
快乐编码:)