Why did this VBS code fail with a "CInt type mismatch error?"

I am having difficulty with the following VBS code. It only works occasionally, and even then it completes quickly. Why?

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 

Error:

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

Please help me, I'm not so good at VBS. It’s clear, my friend helped me write this.

+6
source share
3 answers

As you may already know, an error occurs here

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

And this line does these things

  • InStr , which returns the numeric position of the first occurrence of "> R $"
  • Then it is added with 3 to get the index after the string "R$"
  • Now Mid splits the string St00f with the starting index after "R$" to a length of 8
  • Then Replace takes the separation line and replaces the appearance of "</b>" with ""
  • Finally, CInt converts the string to an integer or more correctly * converts any number to a variant of the Integer subtype *

And you get an error while converting CInt.

If I were in your place, I would split this line by line, leaving only one function in each line, and then try something like MsgBox to output after each line and find what is wrong with that.

The key is the variable St00f and what it has. Happy coding :)

+5
source

The error "Type mismatch" means that your Replace (...) did not return a valid numeric string:

 >> 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 

Consider using IsNumeric () before applying CInt ().

+2
source

CInt can handle between -32,768 and 32,767

Use CLng instead of CInt

Copied from Cint Overflow Error when value exceeds 100,000+

+1
source

Source: https://habr.com/ru/post/908681/


All Articles