Results 1 to 5 of 5

Thread: [VB6] If Statement Calculation Wrong?

  1. #1

    Integra's Avatar
    Joined
    Nov 2013
    Posts
    213
    Userbars
    3
    Thanks
    53
    Thanked
    45/32
    DL/UL
    25/0
    Mentioned
    12 times
    Time Online
    4d 18h 34m
    Avg. Time Online
    1m

    [VB6] If Statement Calculation Wrong?

    Hi all,

    This one is bothering me beyond belief at the moment. I have an if Statement in my current program (Score Sender List Maker) and its working for most games, but then, on the odd game and its a particular game like Escape from Meridell Castle and Meerca Chase II it just goes wrong, wrong wrong!

    Code:
    score = lblPointsToNPS * txtGainNPS
    
    lblTest = score
    Score5 = lblScore5
    lblScore52 = Score5
    
    time = txtWait
    If lblTest > lblScore52 Then
    mMod = 40
    Else
    mMod = txtMod
    End If
    So in the case of Escape from Meridell the lblTest = 310 and the lblScore52 = 1741, now for whatever reason, the game is setting my Mod to 40 which is basically my trigger for saying hey, you can't earn 1000 nps from this game, even though the score is below the high scores :\ Its like its picking something wrong thats not wrong.

  2. #2
    Saiyan Race
    j03's Avatar
    Joined
    Dec 2011
    Posts
    13,735
    Userbars
    175
    Thanks
    5,921
    Thanked
    33,144/6,615
    DL/UL
    23/36
    Mentioned
    3,871 times
    Time Online
    563d 23h 58m
    Avg. Time Online
    3h 13m
    Try this:

    Code:
    score = Val(lblPointsToNPS) * Val(txtGainNPS)  
    
    lblTest = score 
    Score5 = lblScore5 
    lblScore52 = Score5  
    time = txtWait 
    
    If Val(lblTest) > Val(lblScore52) Then 
    mMod = 40 
    Else 
    mMod = txtMod 
    End If
    (you need an account to see links)
    (you need an account to see links)(you need an account to see links)

    ------------------------
    [02/24/2013] Stealth CORE is made into the first standalone Neopets auto-player.
    ------------------------


  3. #3

    Integra's Avatar
    Joined
    Nov 2013
    Posts
    213
    Userbars
    3
    Thanks
    53
    Thanked
    45/32
    DL/UL
    25/0
    Mentioned
    12 times
    Time Online
    4d 18h 34m
    Avg. Time Online
    1m
    Now its throwing an error with my while loop :\ Says I have a Loop without Do but I have the Do .... and no other Do's anywhere:

    Code:
    Dim strHTML As String, score As String, time As String, Score5 As Integer
    Dim mMod As Integer
    
    cmdStart.Enabled = False
    cmdAdd.Enabled = False
    cmdMLoad.Enabled = False
    cmdRemove.Enabled = False
    cmdSaveID.Enabled = False
    cmdCreateIDList.Enabled = False
    
    cmdStop.Enabled = True
    
    Do While index <> lblCountID
        While lblGameName = ""
        strHTML = w.GetWrapper("http://www.neopets.com/games/game.phtml?game_id=" & lstID.List(index), "http://www.neopets.com/games/")
    
        lblGameName = Functions.GSB(strHTML, "og:title" & Chr(34) & " content=" & Chr(34) & "Games Room - ", Chr(34) & "/>")
        txtNPS = Functions.GSB(strHTML, "<div id=" & Chr(34) & "gr-ctp-neopoints-img" & Chr(34) & "></div>", "Points =")
        lblPointsToNPS = Functions.GSB(txtNPS, "<b>", " ")
        lblID = lstID.List(index)
        
        Wend
        
        While lblUser1 = ""
    
        strHTML = w.GetWrapper("http://www.neopets.com/gamescores.phtml?game_id=" & lstID.List(index), w.LastPage)
        lblUser1 = Functions.GSB(strHTML, "<td align=center>1</td>", "b>")
        lblUser1 = Functions.GSB(lblUser1, "<td align=center><a href='randomfriend.phtml?user=", "'>")
        lblScore1 = Functions.GSB(strHTML, lblUser1 & "</b></a></td>", "/td>")
        lblScore1 = Functions.GSB(lblScore1, "=center>", "<")
    
        lblUser2 = Functions.GSB(strHTML, "<td align=center>2</td>", "b>")
        lblUser2 = Functions.GSB(lblUser2, "<td align=center><a href='randomfriend.phtml?user=", "'>")
        lblScore2 = Functions.GSB(strHTML, lblUser2 & "</b></a></td>", "/td>")
        lblScore2 = Functions.GSB(lblScore2, "=center>", "<")
    
        lblUser3 = Functions.GSB(strHTML, "<td align=center>3</td>", "b>")
        lblUser3 = Functions.GSB(lblUser3, "<td align=center><a href='randomfriend.phtml?user=", "'>")
        lblScore3 = Functions.GSB(strHTML, lblUser3 & "</b></a></td>", "/td>")
        lblScore3 = Functions.GSB(lblScore3, "=center>", "<")
    
        lblUser4 = Functions.GSB(strHTML, "<td align=center>4</td>", "b>")
        lblUser4 = Functions.GSB(lblUser4, "<td align=center><a href='randomfriend.phtml?user=", "'>")
        lblScore4 = Functions.GSB(strHTML, lblUser4 & "</b></a></td>", "/td>")
        lblScore4 = Functions.GSB(lblScore4, "=center>", "<")
    
        lblUser5 = Functions.GSB(strHTML, "<td align=center>5</td>", "b>")
        lblUser5 = Functions.GSB(lblUser5, "<td align=center><a href='randomfriend.phtml?user=", "'>")
        lblScore5 = Functions.GSB(strHTML, lblUser5 & "</b></a></td>", "/td>")
        lblScore5 = Functions.GSB(lblScore5, "=center>", "<")
        Wend
        
        If cmdStop.Enabled = False Then
        strHTML = MsgBox("Successfully stopped!", vbOKOnly, "Stopped Auto List!")
        Exit Do
        Else
    
    
    score = Val(lblPointsToNPS) * Val(txtGainNPS)
    
    lblTest = score
    Score5 = lblScore5
    lblScore52 = Score5
    time = txtWait
    
        If Val(lblTest) > Val(lblScore52) Then
        mMod = 40
        Else
        mMod = txtMod
        End If
    
    
    If optAdd1.Value = True Then
    lstList.AddItem ("GameID: " & lblID & " Score: " & score & " Time: " & time & " Mod: " & mMod)
    Else
    If optAdd2.Value = True Then
    lstList.AddItem ("GameID: " & lblID & " Score: " & score & " Time: " & time & " Mod: " & mMod)
    lstList.AddItem ("GameID: " & lblID & " Score: " & score & " Time: " & time & " Mod: " & mMod)
    Else
    If optAdd3.Value = True Then
    lstList.AddItem ("GameID: " & lblID & " Score: " & score & " Time: " & time & " Mod: " & mMod)
    lstList.AddItem ("GameID: " & lblID & " Score: " & score & " Time: " & time & " Mod: " & mMod)
    lstList.AddItem ("GameID: " & lblID & " Score: " & score & " Time: " & time & " Mod: " & mMod)
    End If
    End If
    End If
    
    lblGameName = ""
    lblUser1 = ""
    
    
    index = index + 1
    Loop
    I hate the fact I can't work out what the hell it is doing and why :\

  4. #4
    Zachafer's Avatar
    Joined
    Dec 2011
    Posts
    1,235
    Userbars
    11
    Thanks
    769
    Thanked
    1,466/678
    DL/UL
    98/0
    Mentioned
    512 times
    Time Online
    24d 13h 9m
    Avg. Time Online
    8m
    I properly indented your code and the error popped right out

    Code:
    Dim strHTML As String, score As String, time As String, Score5 As Integer
    Dim mMod As Integer
    
    cmdStart.Enabled = False
    cmdAdd.Enabled = False
    cmdMLoad.Enabled = False
    cmdRemove.Enabled = False
    cmdSaveID.Enabled = False
    cmdCreateIDList.Enabled = False
    
    cmdStop.Enabled = True
    
    Do While index <> lblCountID
    	While lblGameName = ""
    		strHTML = w.GetWrapper("http://www.neopets.com/games/game.phtml?game_id=" & lstID.List(index), "http://www.neopets.com/games/")
    		lblGameName = Functions.GSB(strHTML, "og:title" & Chr(34) & " content=" & Chr(34) & "Games Room - ", Chr(34) & "/>")
    		txtNPS = Functions.GSB(strHTML, "<div id=" & Chr(34) & "gr-ctp-neopoints-img" & Chr(34) & "></div>", "Points =")
    		lblPointsToNPS = Functions.GSB(txtNPS, "<b>", " ")
    		lblID = lstID.List(index)
    	Wend
    
    	While lblUser1 = ""
    		strHTML = w.GetWrapper("http://www.neopets.com/gamescores.phtml?game_id=" & lstID.List(index), w.LastPage)
    		lblUser1 = Functions.GSB(strHTML, "<td align=center>1</td>", "b>")
    		lblUser1 = Functions.GSB(lblUser1, "<td align=center><a href='randomfriend.phtml?user=", "'>")
    		lblScore1 = Functions.GSB(strHTML, lblUser1 & "</b></a></td>", "/td>")
    		lblScore1 = Functions.GSB(lblScore1, "=center>", "<")
    
    		lblUser2 = Functions.GSB(strHTML, "<td align=center>2</td>", "b>")
    		lblUser2 = Functions.GSB(lblUser2, "<td align=center><a href='randomfriend.phtml?user=", "'>")
    		lblScore2 = Functions.GSB(strHTML, lblUser2 & "</b></a></td>", "/td>")
    		lblScore2 = Functions.GSB(lblScore2, "=center>", "<")
    
    		lblUser3 = Functions.GSB(strHTML, "<td align=center>3</td>", "b>")
    		lblUser3 = Functions.GSB(lblUser3, "<td align=center><a href='randomfriend.phtml?user=", "'>")
    		lblScore3 = Functions.GSB(strHTML, lblUser3 & "</b></a></td>", "/td>")
    		lblScore3 = Functions.GSB(lblScore3, "=center>", "<")
    
    		lblUser4 = Functions.GSB(strHTML, "<td align=center>4</td>", "b>")
    		lblUser4 = Functions.GSB(lblUser4, "<td align=center><a href='randomfriend.phtml?user=", "'>")
    		lblScore4 = Functions.GSB(strHTML, lblUser4 & "</b></a></td>", "/td>")
    		lblScore4 = Functions.GSB(lblScore4, "=center>", "<")
    
    		lblUser5 = Functions.GSB(strHTML, "<td align=center>5</td>", "b>")
    		lblUser5 = Functions.GSB(lblUser5, "<td align=center><a href='randomfriend.phtml?user=", "'>")
    		lblScore5 = Functions.GSB(strHTML, lblUser5 & "</b></a></td>", "/td>")
    		lblScore5 = Functions.GSB(lblScore5, "=center>", "<")
    	Wend
    
    	If cmdStop.Enabled = False Then
    		strHTML = MsgBox("Successfully stopped!", vbOKOnly, "Stopped Auto List!")
    		Exit Do
    	Else
    		score = Val(lblPointsToNPS) * Val(txtGainNPS)
    
    		lblTest = score
    		Score5 = lblScore5
    		lblScore52 = Score5
    		time = txtWait
    
    		If Val(lblTest) > Val(lblScore52) Then
    			mMod = 40
    		Else
    			mMod = txtMod
    		End If
    
    		If optAdd1.Value = True Then
    			lstList.AddItem ("GameID: " & lblID & " Score: " & score & " Time: " & time & " Mod: " & mMod)
    		ElseIf optAdd2.Value = True Then
    			lstList.AddItem ("GameID: " & lblID & " Score: " & score & " Time: " & time & " Mod: " & mMod)
    			lstList.AddItem ("GameID: " & lblID & " Score: " & score & " Time: " & time & " Mod: " & mMod)
    		ElseIf optAdd3.Value = True Then
    			lstList.AddItem ("GameID: " & lblID & " Score: " & score & " Time: " & time & " Mod: " & mMod)
    			lstList.AddItem ("GameID: " & lblID & " Score: " & score & " Time: " & time & " Mod: " & mMod)
    			lstList.AddItem ("GameID: " & lblID & " Score: " & score & " Time: " & time & " Mod: " & mMod) 
    		End If
    	End If
    
    	lblGameName = ""
    	lblUser1 = ""
    
    
    	index = index + 1
    Loop

  5. #5

    Integra's Avatar
    Joined
    Nov 2013
    Posts
    213
    Userbars
    3
    Thanks
    53
    Thanked
    45/32
    DL/UL
    25/0
    Mentioned
    12 times
    Time Online
    4d 18h 34m
    Avg. Time Online
    1m
    *sigh* The Uni Lecturer could only get indenting into my head when assignments were needed :\ I suppose I owe you a big thanks then @(you need an account to see links) !!

    However, in light of all this @(you need an account to see links), I still have the issue of not being able to get it to calculate correctly, eg Gadsgads Game which was working fine earlier is now doing the same thing. I don't understand how the if statement can get it wrong if the damn values say that the statement is false and therefore it cannot do what it is doing.

    Its nearly got to be with the formatting of the values stored in the labels doesn't it? The comma's must be throwing something out of whack :\

    Edit:
    Never mind, declaring Score5 as Long instead of Integer would of helped greatly! And reordering some stuff has fixed most of it, now to just clean it up and remove any unnecessary crap!
    Last edited by Integra; 11-17-2013 at 06:12 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •