2012-02-17 145 views
6

我遇到以下VBS代码的困难。它只有时才有效,即使如此也很快失败。为什么?为什么这个VBS代码失败,出现“类型不匹配:'CInt''错误?

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 

错误:

Script: C:\Users\John\Downloads\SingleHatSniper.vbs 
Line:  14 
Char:  1 
Error: Type mismatch: 'CInt' 
Code:  800A000D 
Source: Microsoft VBScript runtime error 

请帮助我,我不是VBS很大。这很明显,我的朋友帮我写了这个。

+2

复制我不会有任何帮助,但“对接”已是最痛苦的名称可能。我只会在我试图调用方法的时候咯咯笑起来。 “尽管Butt.Busy”? Heeheeheehee。 – Interrobang 2012-02-17 06:07:16

+0

请为您的问题选择一个正确的标题,以让人们对其感兴趣。 “你能通过这个来引导我吗?”对你的问题一无所知。 – deceze 2012-02-17 06:08:10

+0

@Inter与名称为“Interrobang”的配对使得它非常具有启发性,不是吗?-P – deceze 2012-02-17 06:09:48

回答

5

正如你现在可能已经知道,这是在错误发生

St00f = CInt(Replace(Mid(St00f, (InStr(St00f, ">R$")+3), 8), "</b>", "")) 

这行做这些事

  1. InStr返回的“第一次出现的数字位置> R $“
  2. 然后再加上3来得到字符串后的索引"R$"
  3. 现在Mid拆分串St00f与起始索引"R$"后的8
  4. 然后Replace的长度取分割字符串和替换的"</b>"""
  5. 发生最后CInt字符串转换为整数或更正确*将任何编号到整型变体*

而且您在CInt转换中出现错误。

如果我在你的位置,我将通过每行只保留一个函数来分割这一行,然后在每行之后尝试诸如MsgBox之类的输出,并找出其中的错误。

关键是变量St00f和那个变量保持。
快乐编码:)

2

“类型不匹配”错误表明您更换(...)没有返回一个有效的数字字符串

>> i = CInt("4711") 
>> 
>> i = CInt("999999999999") 
>> 
Error Number:  6 
Error Description: Overflow 
>> i = CInt("no number") 
>> 
Error Number:  13 
Error Description: Type mismatch 
>> i = CInt("") 
>> 
Error Number:  13 
Error Description: Type mismatch 

考虑使用则IsNumeric()应用CINT之前( )。

相关问题