[2008] Getting The Data You Need from a website
Using webcontrol i am able to transfer the html code to a textbox but i need the data of amount of refferals some of the text is
# of Referrals (view)X
X are the number of refferals of the person how can i get the value of X
I tried the data split code but it didnt help
Code:
dim data as string = textbox1.text
dim Split() as string = data.split(" "c)
'bla bla but it didnt work
I just wanted to ask is there any simpler and better way?
Re: [2008] Getting The Data You Need from a website
You need to study the text data and look for special patterns. Once you find a pattern, you can use regex to find matches to that pattern. However, if you just want to look for a value that follows right after the term "# of Referrals (view)", you can use string.indexof to find the start index of the term, and from there, you can extract what you need using string.substring function.
Re: [2008] Getting The Data You Need from a website
Quote:
Originally Posted by stanav
You need to study the text data and look for special patterns. Once you find a pattern, you can use regex to find matches to that pattern. However, if you just want to look for a value that follows right after the term "# of Referrals (view)", you can use string.indexof to find the start index of the term, and from there, you can extract what you need using string.substring function.
Can You Please Give An Example
Re: [2008] Getting The Data You Need from a website
Re: [2008] Getting The Data You Need from a website
vb Code:
Dim C As String = "dfdh dhd dashd dfhsdif disdfh hisasf # of Referrals (view)25 asdsa dsa"
Dim A As String = C.IndexOf("# of Referrals (view)")
Dim retString As String
retString = C.Substring(21, 1)
MsgBox(retString)
Tried this but it didnt work:(
Re: [2008] Getting The Data You Need from a website
You aren't even using 'A' in that code...
Re: [2008] Getting The Data You Need from a website
Quote:
Originally Posted by Orbit__
vb Code:
Dim C As String = "dfdh dhd dashd dfhsdif disdfh hisasf # of Referrals (view)25 asdsa dsa"
Dim A As String = C.IndexOf("# of Referrals (view)")
Dim retString As String
retString = C.Substring(21, 1)
MsgBox(retString)
Tried this but it didnt work:(
You almost got it right.... It should be something like this:
Code:
Dim C As String = "dfdh dhd dashd dfhsdif disdfh hisasf # of Referrals (view)25 asdsa dsa"
Dim searchTerm As String = "# of Referrals (view)"
Dim numberOfCharactersToGet As Integer = 2
Dim retString As String = String.Empty
Dim index As Integer = C.IndexOf(searchTerm)
If index >= 0 Then
Try
retString = C.Substring(index + searchTerm.Length, numberOfCharactersToGet)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End If
MessageBox.Show(retString)