|
-
Sep 21st, 2003, 05:51 AM
#1
Thread Starter
Fanatic Member
How would you loop a string
hi all i have a string which im preforming certain case matches
by instr function
however my script only matches one item in the string so there for i need to loop it
how would you loop a string ???? until there is no more of the string left to loop
Cheers All
I am curretly building a defect management system for software and web developers,
If you wana try it out (beta test) and keep it for free just send me a message
-
Sep 21st, 2003, 06:16 AM
#2
like this you mean?....
VB Code:
[color=blue]Dim[/color] strString [color=blue]As String[/color]() = "some stuff with spaces in to seperate!".Split(" ")
[color=blue]Dim[/color] strResult [color=blue]As String[/color]
[color=blue]For Each[/color] strResult [color=blue]In[/color] strString
MessageBox.Show(strResult)
[color=blue]Next[/color]
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
-
Sep 21st, 2003, 06:35 AM
#3
Thread Starter
Fanatic Member
Sorry should really show more code
Start:
do while "ant got a clue" basically until the string is all used up
'------------------------------------------------------------------------
'Start filtering for the links within the source code
'------------------------------------------------------------------------
StartPoint = 1
StartPos = InStr(StartPoint, LineOfSite, "<a href=", vbTextCompare)
If StartPos > 0 Then
EndPos = InStr(StartPos, LineOfSite, Chr(62), vbTextCompare) 'Get the end part of the link
If EndPos = 0 Then GoTo Restart_Loop
LinkLength = EndPos - StartPos
TheLink = Trim$(Mid$(LineOfSite, StartPos + 8, LinkLength - 8))
If InStr(1, TheLink, " ") <> 0 Then
TheLink = Trim$(Microsoft.VisualBasic.Left$(TheLink, InStr(1, TheLink, " ")))
End If
If Microsoft.VisualBasic.Left$(TheLink, 1) = Chr(34) Then
TheLink = Mid$(TheLink, 2)
End If
If Microsoft.VisualBasic.Right$(TheLink, 1) = Chr(34) Then
TheLink = Microsoft.VisualBasic.Left$(TheLink, Len(TheLink) - 1)
End If
'only get the urls that start with http
'If Not Microsoft.VisualBasic.Left$(TheLink, 4) = "http" Then GoTo Restart_Loop
'If Microsoft.VisualBasic.Left$(TheLink, 1) = "/" Then GoTo Restart_Loop
'Skip allot of format
If Microsoft.VisualBasic.Right$(TheLink, 4) = ".gif" Then GoTo Restart_Loop
If Microsoft.VisualBasic.Right$(TheLink, 4) = ".jpg" Then GoTo Restart_Loop
If Microsoft.VisualBasic.Right$(TheLink, 4) = ".png" Then GoTo Restart_Loop
If Microsoft.VisualBasic.Right$(TheLink, 4) = ".mpg" Then GoTo Restart_Loop
If Microsoft.VisualBasic.Right$(TheLink, 4) = ".avi" Then GoTo Restart_Loop
If Microsoft.VisualBasic.Right$(TheLink, 3) = ".rm" Then GoTo Restart_Loop
If Microsoft.VisualBasic.Right$(TheLink, 3) = ".ra" Then GoTo Restart_Loop
If Microsoft.VisualBasic.Right$(TheLink, 4) = ".wav" Then GoTo Restart_Loop
If Microsoft.VisualBasic.Right$(TheLink, 4) = ".mp3" Then GoTo Restart_Loop
If Microsoft.VisualBasic.Right$(TheLink, 4) = ".asp" Then GoTo Restart_Loop
If Microsoft.VisualBasic.Right$(TheLink, 4) = ".php" Then GoTo Restart_Loop
If Microsoft.VisualBasic.Right$(TheLink, 4) = ".jsp" Then GoTo Restart_Loop
If Microsoft.VisualBasic.Right$(TheLink, 5) = ".aspx" Then GoTo Restart_Loop
End If
'------------------------------------------------------------------------
'End Filtering the links
'------------------------------------------------------------------------
strLinks = strLinks & TheLink & vbCrLf
Restart_Loop:
Loop
I am curretly building a defect management system for software and web developers,
If you wana try it out (beta test) and keep it for free just send me a message
-
Sep 21st, 2003, 08:21 AM
#4
Frenzied Member
To make your job easier you could use regular expression or you might want to use recursion
-
Sep 21st, 2003, 09:41 AM
#5
Thread Starter
Fanatic Member
hey?
IM trying to extract links from webpages so i guessed what i need to do is
1 get the source code - done
2 filter it for pages - kinda done Only finds one page hence why need the loop
3 deal with the links
this is why i was wondering how you loop via a string until the string has nothing left ?
I am curretly building a defect management system for software and web developers,
If you wana try it out (beta test) and keep it for free just send me a message
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|