|
-
Jun 20th, 2003, 04:46 PM
#1
Thread Starter
Lively Member
what would be the syntax...
To search a textbox for a string and then find whatever is to the right of that string?
-
Jun 20th, 2003, 05:32 PM
#2
You can use the IndexOf method to find a string inside another string or at least where the inner string starts at. The SubString method will get the string after that point.
VB Code:
Dim inner As String = "the"
Dim whole As String = "back in the valley..."
MsgBox(whole.Substring(whole.IndexOf(inner)))
'returns 'the valley...'
-
Jun 20th, 2003, 05:46 PM
#3
Thread Starter
Lively Member
Sweet.... now with that, am i able to set it so it only finds so many chars after the keyword?
-
Jun 20th, 2003, 06:03 PM
#4
Yeah, check out the help in the SubString method. You can pass a 2nd parameter in which is the length from the start to return.
VB Code:
Dim inner As String = "the"
Dim whole As String = "back in the valley..."
MsgBox(whole.Substring(whole.IndexOf(inner), 5))
'returns 'the v'
-
Jun 20th, 2003, 06:15 PM
#5
Thread Starter
Lively Member
Thank you SO much for your help so far
-
Jun 20th, 2003, 07:48 PM
#6
Thread Starter
Lively Member
I think this should be the last one
I have this string:
<html><head><title>VN Boards - *users* Profile</title>
I want to get just the username, which can be up to 20 chars, how can i get from the beginning to the end?
-
Jun 20th, 2003, 09:16 PM
#7
What you want to do is get the text between the - and the space after the name. Soo....
VB Code:
Dim sText As String
Dim sUser As String
Dim iStart As Integer
Dim iEnd As Integer
sText = "<html><head><title>VN Boards - *users* Profile</title>"
iStart = sText.IndexOf("-") + 1 ' add one for the space
iEnd = sText.LastIndexOf(" ") ' last space will be between user and profile
sUser = sText.Substr(iStart, iEnd - iStart).Trim()
untested, should work.
Every passing hour brings the Solar System forty-three thousand miles closer to Globular Cluster M13 in Hercules -- and still there are some misfits who insist that there is no such thing as progress.
-
Jun 20th, 2003, 10:34 PM
#8
Thread Starter
Lively Member
Cool sun, it works... Can i use the same method to get this?
Code:
Posts Total:
</td>
<td width=85% class="BoardRowB">
6,499
keep in mind, the number is always changing
Ive tried numerous things, but cant seem to get it
-
Jun 21st, 2003, 01:10 PM
#9
yay gay
it should be dead easy as long as u know what appears after that number, so you can look for the <td width=85% class="BoardRowB"> and then for the thing that is after it , subtract to get the lenght of the number and then use the .substring() method
\m/  \m/
-
Jun 21st, 2003, 08:45 PM
#10
Thread Starter
Lively Member
heh... actually thats a bit tough....
everything uses
<td width=85% class="BoardRowB"> in it
-
Jun 21st, 2003, 08:47 PM
#11
yay gay
be smart, look for references, like the 5th's <td width=85% class="BoardRowB"> or something like that
\m/  \m/
-
Jun 21st, 2003, 09:57 PM
#12
Thread Starter
Lively Member
heh... i got it, i looked from posts total, and then looked so many spaces in until the number started and ended at the space after the number
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
|