ThyElite Forums

ThyElite Forums (http://www.thyelite.com/forum/index.php)
-   Help! (http://www.thyelite.com/forum/forumdisplay.php?f=9)
-   -   Visual Basic Help? (http://www.thyelite.com/forum/showthread.php?t=1370)

Sifter 07-28-2006 11:42 PM

Visual Basic Help?
 
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:
Code:

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;
Code:

http://mycoke.com/sumo.do?screenname=USER&prize=1
If successful, it will return with something saying
Code:

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

Heff 07-29-2006 12:06 AM

Add this function:
Code:

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

Code:

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.

Heff 07-29-2006 12:47 AM

Let me see your source.

Sifter 07-29-2006 01:55 AM

Code:

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



All times are GMT -6. The time now is 12:07 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.