It is currently Wed Sep 08, 2010 2:37 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: quick question
PostPosted: Wed Apr 15, 2009 4:03 am 
Offline
User avatar
.: Level III :.

Joined: Sun Jun 10, 2007 4:37 am
Posts: 653
Location: under a rock
iTrader:
Gender: Male
Cash:33
Reputation point: 39
ceneret0023 has a spectacular aura about themceneret0023 has a spectacular aura about them


Winner Award

If i'm using the GetStringBetween function how can i make it move to the next line with the start and end val?

for example:

<img src="google.com/page1">
<img src="google.com/page2">

and i want it to tell me what's in between google.com/ and the last " how would i have it tell me page1 and then loop back through and tell me page2?

i know the for i= lbound to ubound thing i mean have the function go to the next line of the source.


thanks in advanced :)

_________________
Image
Check out my guides :)


Top
 Profile  
 
 Post subject: Re: quick question
PostPosted: Wed Apr 15, 2009 5:57 am 
Offline
User avatar
.: Level I :.

Joined: Tue Apr 14, 2009 6:21 am
Posts: 88
Location: Daytona Beach, FL
iTrader:
Gender: Male
Cash:177
Reputation point: 31
Brian has a spectacular aura about themBrian has a spectacular aura about them
Basically what you are doing is searching a string for a smaller string, it return's the char position of what you are searching for so instead of starting at the beginning you need to make it start from where your search ended. not that difficult..
So... This need some changes(just to the function declaration) but it should give you a good idea of what is needed...
Code:
    Dim LastResult As String
    Public Function ForEach(ByVal Source As String, ByVal Start As String, ByVal Finish As String) As String
        Dim Result = ""
        Dim LastResult As String = ""

        Dim A = InStr(1, Source, Start) + Len(Start)

        Do Until Result = ""
            If A = 0 Then
                Result = ""
                Return Result
            Else
                Dim B = InStr(A, Source, Finish)
                If B = 0 Then
                    Result = ""
                    Return Result
                Else
                    Result = Mid(Source, A, B - A)
                    Return Result
                    LastResult = Result
                    A = InStr(B, Source, Start) + Len(Start)
                End If
            End If
        Loop
    End Function

_________________
Image


Top
 Profile  
 
 Post subject: Re: quick question
PostPosted: Sun Apr 19, 2009 4:13 pm 
Offline
User avatar
.: Level III :.

Joined: Sun Jun 10, 2007 4:37 am
Posts: 653
Location: under a rock
iTrader:
Gender: Male
Cash:33
Reputation point: 39
ceneret0023 has a spectacular aura about themceneret0023 has a spectacular aura about them


Winner Award

I've tried using your code to adapt mine to yours but whenever i try to use it nothing happens, i hit my command button and the program just sits there, it doesn't even act like it's working. Also what is the code you put up in? i'm using vb6 and a lot of the functions you used don't work with vb6...

_________________
Image
Check out my guides :)


Top
 Profile  
 
 Post subject: Re: quick question
PostPosted: Sun Apr 19, 2009 7:23 pm 
Offline
User avatar
.: Level I :.

Joined: Tue Apr 14, 2009 6:21 am
Posts: 88
Location: Daytona Beach, FL
iTrader:
Gender: Male
Cash:177
Reputation point: 31
Brian has a spectacular aura about themBrian has a spectacular aura about them
Here to make life easy as possible for you..
Code:
Public Function ExtractAll(SearchString As String, StartString As String, EndString As String, AddToList As ListBox) As String

Dim Temp As Long, temp1 As Long, temp2 As Long, temp3 As Long
temp1 = 1

Do While InStr(temp1, SearchString, StartString, vbTextCompare) <> 0
Temp = InStr(temp1, SearchString, StartString, vbTextCompare) + Len(StartString)
temp2 = InStr(Temp, SearchString, EndString, vbTextCompare)
temp3 = temp2 - Temp
temp1 = temp2 + 1
AddToList.AddItem (Mid$(SearchString, Temp, temp3))
Loop
End Function

_________________
Image


Top
 Profile  
 
 Post subject: Re: quick question
PostPosted: Sun Apr 19, 2009 7:41 pm 
Offline
User avatar
.: Level III :.

Joined: Sun Jun 10, 2007 4:37 am
Posts: 653
Location: under a rock
iTrader:
Gender: Male
Cash:33
Reputation point: 39
ceneret0023 has a spectacular aura about themceneret0023 has a spectacular aura about them


Winner Award

i understand what i need to do and what the code is doing(that's the code i've been using), looking through your first code really helped me understand what i needed to do, its just i'm having trouble applying it to the code. What happens when i try to add the loop is either it doesn't do anything at all when i click my command button or it just gives me tons of blank spaces. I wasn't trying to ask for the exact code, i'm sorry if that's what it sounded like, but i'm just having trouble applying what you've said i should do.

Code:
Public Function GetStringBetween(ByVal InputText As String, _
     ByVal StartText As String, _
     ByVal EndText As String, _
     Optional ByVal StartPosition = 1) As String
 
     Dim lnTextStart As Long
     Dim lnTextEnd As Long
 
    Do Until GetStringBetween = ""
     lnTextStart = InStr(StartPosition, InputText, StartText, vbTextCompare) + Len(StartText)
     lnTextEnd = InStr(lnTextStart, InputText, EndText, vbTextCompare)
     If lnTextStart >= (StartPosition + Len(StartText)) And lnTextEnd > lnTextStart Then
         GetStringBetween = Mid$(InputText, lnTextStart, lnTextEnd - lnTextStart)
         StartPosition = lnTextEnd
     Else
         GetStringBetween = ""
     End If
    Loop
   
End Function


this is what i've changed it to and i know i'm probably using what you said too directly but from what i gather it only needs the one loop to have it go back around and search again from the end of the last search the StartPosition = lnTextEnd and it needs to do that until the GetStringBetween="" and i know its proabably not quite as simple as that but that's what i've gathered from looking at your code and trying to use what you told me...

_________________
Image
Check out my guides :)


Top
 Profile  
 
 Post subject: Re: quick question
PostPosted: Sun Apr 19, 2009 11:10 pm 
Offline
User avatar
.: Level I :.

Joined: Tue Apr 14, 2009 6:21 am
Posts: 88
Location: Daytona Beach, FL
iTrader:
Gender: Male
Cash:177
Reputation point: 31
Brian has a spectacular aura about themBrian has a spectacular aura about them
Well this is in .net but it works and you should get the idea here.
Code:
    Public Function GetAll(ByRef Source As String, ByRef Start As String, ByRef Finish As String, ByVal myListbox As ListBox, Optional ByRef iStart As Integer = 0) As String
        Dim iFinish As Integer
        Dim Result As String
        Dim FoundAll As Boolean = False
        iStart = InStr(1, Source, Start) + Len(Start)
        Do While iStart > 0
            Result = String.Empty
            iFinish = InStr(iStart, Source, Finish)
            If iFinish = 0 Then
                FoundAll = True
            End If
            Result = Mid(Source, iStart, iFinish - iStart)
            iStart = InStr(iFinish, Source, Start) + Len(Start)
            SetText(ListBox_Items, Result)
            If InStr(iStart, Source, Start, CompareMethod.Binary) = 0 Then
                Exit Do
            End If
        Loop
    End Function

_________________
Image


Top
 Profile  
 
 Post subject: Re: quick question
PostPosted: Thu Apr 30, 2009 9:41 pm 
Offline
.: Newbie :.

Joined: Mon Apr 09, 2007 1:49 am
Posts: 825
iTrader:
Gender: Male
Cash:16
Reputation point: 0
Snowman is an unknown quantity at this point
add theses two functions

Public Function ParseRight(What As String, StopAt As String) As String
On Error GoTo PErr
ParseRight = Mid(What, InStr(What, StopAt) - 1)

Exit Function
PErr:
ParseRight = "Search string does not exist"
End Function

Public Function ParseLeft(What As String, StopAt As String) As String
On Error GoTo PErr
ParseLeft = Left(What, InStr(What, StopAt) - 1)

Exit Function
PErr:
ParseLeft = "Search string does not exist"
End Function

so do this:

newtext.text = Parseright(text.text, "src=")
newtext.text = parseleft(newtext.text, "img src")
whatyouwant.text = getbetween(newtext.text, ".com/", ">")
whatyouwant.text = Replace(whatyouwant.text, ",", "")

thatll get you page1

newtext2.text = Parseright(text2.text, ".com")
whatyouwant.text = getbetween(newtext.text, ".com/", ">")
whatyouwant.text = Replace(whatyouwant.text, ",", "")

that should get you page 2

tell me how it goes

_________________
Image
Programs:
NP GEN- 98% done
Auto-pricer
Cellblock AP
Neoboard Spammer


Top
 Profile  
 
 Post subject: Re: quick question
PostPosted: Fri May 01, 2009 2:54 pm 
Offline
User avatar
.: Level III :.

Joined: Sun Jun 10, 2007 4:37 am
Posts: 653
Location: under a rock
iTrader:
Gender: Male
Cash:33
Reputation point: 39
ceneret0023 has a spectacular aura about themceneret0023 has a spectacular aura about them


Winner Award

Thanks for the help Snowmann but i had already figured it out... i really appreciate your trying to help though :)

_________________
Image
Check out my guides :)


Top
 Profile  
 
 Post subject: Re: quick question
PostPosted: Sat May 02, 2009 5:33 am 
Offline
.: Newbie :.

Joined: Mon Apr 09, 2007 1:49 am
Posts: 825
iTrader:
Gender: Male
Cash:16
Reputation point: 0
Snowman is an unknown quantity at this point
ohhh sorry hahaha. but keep these parse function, theyre really good when trying to single out text.

_________________
Image
Programs:
NP GEN- 98% done
Auto-pricer
Cellblock AP
Neoboard Spammer


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
* FAQ

Powered by phpBB © 2000-2008 phpBB Group
NEOPETS, characters, logos, names and all related indicia are trademarks of Neopets, Inc., © 1999-2008. © denotes Reg. US Pat. & TM Office. All rights reserved.
Website © 2008 neofriends.net - this site is in no way affiliated with Neopets, Inc or Viacom International, Inc.

phpBB SEO