Quantcast

Jump to content


Photo

[vb.NET] Money Tree NP Grabber


  • Please log in to reply
3 replies to this topic

#1 Backslash

Backslash
  • 47 posts

Posted 22 November 2009 - 02:17 PM

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
 	If NeoLogin.LoggedIn = False Then
 	MsgBox("You have to be logged in before you can start the program!", MsgBoxStyle.Critical, "Not Logged In!")
 	Exit Sub
 	End If
 	Button1.Enabled = False : Button2.Enabled = True
 	Dim strSub As String
 	strHTML = Wrapper.GetWrapper("http://www.neopets.com/donations.phtml", "http://www.neopets.com/donations.phtml")
 	strSub = GetStringBetween(strHTML, "objects.phtml?type=inventory"">", "</a>")
 	lblNPs.Text = strSub
 	lstTree.Items.Clear()
 	ListBox1.Items.Clear()
 	GBA(strHTML, "<IMG src=""http://images.neopets.com/images/moneybag.gif"" width=""80"" height=""80"" border=""1""></A><BR><B>", " NP</B>", lstTree)
 	GBA(strHTML, "takedonation_new.phtml?", """><IMG src=""http://images.neopets.com/images/m", ListBox1)
 	lstLog.Text += CurrentTime() + "Found " & lstTree.Items.Count & " bags of NP!" + vbNewLine

	End Sub
As you can see in the code above, I have two list boxes named lstTree and lstID
lstTree contains the amount of NP in the bag(if there is any on the page) and lstID has the Link to them
The problem is, when I run the first GBA, it works perfectly, but the second one freezes my form. I've tried many ways to troubleshoot this with no luck. Anyone can help? Thanks.


EDIT: Sorry lsTID = Listbox1

Edited by Backslash, 22 November 2009 - 02:32 PM.


#2 Dan

Dan
  • Resident Know-It-All

  • 6382 posts


Users Awards

Posted 22 November 2009 - 02:38 PM

Post your GBA method - not entirely sure what that's meant to signify.

#3 Backslash

Backslash
  • 47 posts

Posted 22 November 2009 - 02:45 PM

Public Function GBA(ByRef strSource As String, ByRef strStart As String, ByRef strEnd As String, ByVal lstAdd As ListBox, Optional ByRef startPos As Integer = 0) As String
 	Dim iPos As Integer, iEnd As Integer, strResult As String, lenStart As Integer = strStart.Length

 	Do Until iPos = -1
 	strResult = String.Empty
 	iPos = strSource.IndexOf(strStart, startPos)
 	iEnd = strSource.IndexOf(strEnd, iPos + lenStart)
 	If iPos <> -1 AndAlso iEnd <> -1 Then
 	strResult = strSource.Substring(iPos + lenStart, iEnd - (iPos + lenStart))
 	lstAdd.Items.Add(strResult)
 	startPos = iPos + lenStart
 	End If
 	Loop

 	GBA = ""
	End Function

Its from CodeKeep.net

#4 ((_Blade_))

((_Blade_))
  • 20 posts

Posted 22 November 2009 - 02:46 PM

The problem is, when I run the first GBA, it works perfectly, but the second one freezes my form. I've tried many ways to troubleshoot this with no luck. Anyone can help? Thanks.

Your GBA function is stuck in an infinite loop...
Most likely it's missing a few conditional statements to escape the loop if no search strings are found.

Post your GBA source code as well so we can have a look..

EDIT: Ignore this post :p (Damn...thats what you get for typing too slow)

Edited by ((_Blade_)), 22 November 2009 - 02:48 PM.



1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users