To search a textbox for a string and then find whatever is to the right of that string?
Printable View
To search a textbox for a string and then find whatever is to the right of that string?
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...'
Sweet.... now with that, am i able to set it so it only finds so many chars after the keyword?
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'
Thank you SO much for your help so far :)
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?
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.
Cool sun, it works... Can i use the same method to get this?
keep in mind, the number is always changingCode:Posts Total:
</td>
<td width=85% class="BoardRowB">
6,499
Ive tried numerous things, but cant seem to get it
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
heh... actually thats a bit tough....
everything uses
<td width=85% class="BoardRowB"> in it
be smart, look for references, like the 5th's <td width=85% class="BoardRowB"> or something like that
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