PDA

View Full Version : [VB6] Run time error '13' Type mismatch



Ashleys165
09-03-2012, 10:04 AM
Probably something stupid, but I'm tired and I want to get this shit done. So...



Private Sub Command1_Click()
Dim strhtml As String


a = 0
If Text1 > 10 Then
Log.AddItem "The Max. # of eggs"
Log.AddItem " can select is 10."
ElseIf Text3 > Label6 Then
Log.AddItem "You cannot bet more than"
Log.AddItem Label6 & "neopoints!"
Else
Log.AddItem "Started Gambling"
c = 0

endnp = 0
endnp = (GetStringBetween(strhtml, "NP: <a id='npanchor' href=""/objects.phtml?type=inventory"">", "</a>"))



Do Until c = Text


'(my secret stuffs xD)


Loop
np = (GetStringBetween(strhtml, "NP: <a id='npanchor' href=""/objects.phtml?type=inventory"">", "</a>"))
NPOH1 = np & " Neopoints On Hand"

Log.AddItem "Total Profit: " & np - endnp & " Neopoints." 'I am being told that endnp has no value "" But the green part should give it value
Log.AddItem "Done Gambling"
End If
End Sub


Help me, I'm about to fall asleep at the computer and have nightmares about the code. :/

+REP :)

PS: I just decided to remove everything in the loop for the sake of not being copied and I still have to add human-like qualities, plus it looks a bit sad. If you need to see it, PM me please.

Ashleys165
09-03-2012, 02:34 PM
Miguel

now it highlights

endnp = CInt(GetStringBetween(strhtml, "NP: <a id='npanchor' href=""/objects.phtml?type=inventory"">", "</a>"))
And when I put my cursor over endnp it just says "endnp = Empty"

And btw, endnp is just the beginning number of neopoints (I know it says end but it was just a name) np is the ending number.

Ashleys165
09-03-2012, 03:55 PM
np and endnp are both strings... I probably should have mentioned that...

j03
09-03-2012, 04:28 PM
Are you taking the commas out of the NP?

endnp = replace(endnp, "," , "")

before you do any number stuff with it

DarkByte
09-03-2012, 04:51 PM
Use a long a ints max value is 327627 .

Hexx
09-03-2012, 05:28 PM
Use a long a ints max value is 327627 .

is it not even smaller than that? i always thought it was around 32k.

DarkByte
09-03-2012, 05:30 PM
It is i probly added a number lol had issues with it before when making a aber, would not buy anything over 32k

Zachafer
09-04-2012, 09:13 PM
is it not even smaller than that? i always thought it was around 32k.
An Integer (in vb6) is 2 bytes, ranging from -32768 to 32767. Longs can go up to (2^31-1) which is slightly over 2.147 billion.



Private Sub Command1_Click()
Dim strhtml As String


a = 0
If Text1 > 10 Then 'Specify you are comparing Text1.Text (also convert .Text to an integer)
Log.AddItem "The Max. # of eggs"
Log.AddItem " can select is 10."
ElseIf Text3 > Label6 Then 'Specify you are comparing .Text and .Caption respectively. Convert both to integers
Log.AddItem "You cannot bet more than"
Log.AddItem Label6 & "neopoints!" '.Text
Else
Log.AddItem "Started Gambling"
c = 0

' endnp = 0
endnp = CInt(Replace(GetStringBetween(strhtml, "NP: <a id='npanchor' href=""/objects.phtml?type=inventory"">", "</a>"), ",", vbNullString)) 'assuming endnp is an integer



Do Until c = Text 'Try using c >= Text


'(my secret stuffs xD)


Loop
np = CInt(Replace(GetStringBetween(strhtml, "NP: <a id='npanchor' href=""/objects.phtml?type=inventory"">", "</a>"), ",", vbNullString)) 'assuming np is an integer
NPOH1 = np & " Neopoints On Hand" '.Caption

Log.AddItem "Total Profit: " & (np - endnp) & " Neopoints."
Log.AddItem "Done Gambling"
End If
End SubRead the comments I included.