View Full Version : Visual Basic Help?
Sifter
07-28-2006, 11:42 PM
I'm currently working on a newer, better version of SumoPrizeGrabber. I need to know how to make a status checker in Inet for one of the prizes.
Heres the URL for inet to connect to:
http://mycoke.com/sumo.do?screenname=" + Text1.Text + "&prize=1
The text1 is a textbox with your vegos name, for example, if your username was USER; http://mycoke.com/sumo.do?screenname=USER&prize=1
If successful, it will return with something saying <result code="0" /> If it says anything else, it's unsuccessful. How do i make a status checker that checks what is returned and says either Failed, or Success On a label named Label3?
Add this function:
Public Function GetStringBetween(ByVal InputText As String, _
ByVal StartText As String, _
ByVal EndText As String, _
Optional ByVal StartPosition = 1) As String
'Standard Function as supplied by Mumei - NOT case sensitive and uses mid, not mid$
Dim lnTextStart As Long
Dim lnTextEnd As Long
lnTextStart = InStr(StartPosition, InputText, StartText, vbTextCompare) + Len(StartText)
lnTextEnd = InStr(lnTextStart, InputText, EndText, vbTextCompare)
If lnTextStart >= (StartPosition + Len(StartText)) And lnTextEnd > lnTextStart Then
'we've found the entry
GetStringBetween = Mid(InputText, lnTextStart, lnTextEnd - lnTextStart)
Else
GetStringBetween = ""
End If
End Function
Here's how to make success/failed
Buffer = WebBrowser3.Navigate ("http://www.mycoke.com/sumo.do?screenname=" + Text1.Text + "&prize=3")
If code="0" = GetStringBetween(Buffer, "<result", "/>") Then
lblStatus = "Success"
Else
lblStatus = "Failed"
End If
UNTESTED
Sifter
07-29-2006, 12:11 AM
Thanks, but uh... where do I put the second one in?
EDIT: Nevermind, i got it, by deleting the Buffer = part. But it comes up with Failed no matter what, and how do i make it work for all 3? Individually i mean.
EDIT2: It pretty much works, just now it instantly makes it say Failed.
Sifter
07-29-2006, 01:55 AM
Public Function GetStringBetween(ByVal InputText As String, _
ByVal StartText As String, _
ByVal EndText As String, _
Optional ByVal StartPosition = 1) As String
'Standard Function as supplied by Mumei - NOT case sensitive and uses mid, not mid$
Dim lnTextStart As Long
Dim lnTextEnd As Long
lnTextStart = InStr(StartPosition, InputText, StartText, vbTextCompare) + Len(StartText)
lnTextEnd = InStr(lnTextStart, InputText, EndText, vbTextCompare)
If lnTextStart >= (StartPosition + Len(StartText)) And lnTextEnd > lnTextStart Then
'we've found the entry
GetStringBetween = Mid(InputText, lnTextStart, lnTextEnd - lnTextStart)
Else
GetStringBetween = ""
End If
End Function
Private Sub Command1_Click()
WebBrowser1.Navigate ("http://mycoke.com/sumo.do?screenname=" + Text1.Text + "&prize=1")
If code = "0" = GetStringBetween(Buffer, "<result code=", "/>") Then
Label3.Caption = "Success!"
Else
Label3.Caption = "Failed."
End If
WebBrowser2.Navigate ("http://mycoke.com/sumo.do?screenname=" + Text1.Text + "&prize=2")
If code = "0" = GetStringBetween(Buffer, "<result", "/>") Then
Label4.Caption = "Success!"
Else
Label4.Caption = "Failed."
End If
WebBrowser3.Navigate ("http://www.mycoke.com/sumo.do?screenname=" + Text1.Text + "&prize=3")
If code = "0" = GetStringBetween(Buffer, "<result code=", "/>") Then
Label5.Caption = "Success!"
Else
Label5.Caption = "Failed."
End If
End Sub
http://www.geocities.com/ptwomble/look.PNG
vBulletin® v3.6.8, Copyright ©2000-2025, Jelsoft Enterprises Ltd.