S
Sarah
Hi -
I am extremely new to programming so I apologize in advance for my lack
of knowlege, vocabulary and if my code is sloppy. I will take any
suggestions to clean up my code and to follow any best pratices that I
missed. I am taking a stab at writing a program through Visual Basic
2005 Express Edition that will (don't laugh...) keep track, search
through and find new friends with specific interests on myspace. The
functionality of myspace is quite a let down so I thought I would try
to create a program to fill my need. I am stuck at the moment on
trying to do a httpWebRequest and regex to give me an output into a
textbox of friend IDs. Here my code so far that I have figured out
through researching the boards, msdn and using Expresso for my regular
expression:
' Imports System.Text.RegularExpressions
Private Sub GetIDsButton_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles GetIDsButton.Click
Dim myURL As String = ToolStripTextBox1.Text
Dim myReg As Net.HttpWebRequest =
DirectCast(Net.WebRequest.Create(myURL), _
Net.HttpWebRequest)
Dim myResp As Net.HttpWebResponse = _
DirectCast(myReg.GetResponse(), Net.HttpWebResponse)
Dim myStream As IO.Stream = myResp.GetResponseStream()
Dim myreader As New IO.StreamReader(myStream)
Dim myPage As String = myreader.ReadToEnd()
myResp.Close()
'' Regular expression built for Visual Basic on: Thu, Jul 6,
2006, 12:07:39 PM
'' Using Expresso Version: 2.1.2150, http://www.ultrapico.com
''
'' A description of the regular expression:
'' '' [1]: A numbered capture group. [\d{5,9}]
'' Any digit, between 5 and 9 repetitions
'' Match a suffix but exclude it from the capture. ["><img\b]
'' "><img\b
'' "><img
'' First or last character in a word
'
Dim r As Regex = New Regex( _
"(\d{5,9})(?=""><img\b)" + vbCrLf + "", _
RegexOptions.IgnoreCase _
Or RegexOptions.IgnorePatternWhitespace _
)
Dim m As RegularExpressions.Match
Dim mLink As RegularExpressions.Match
For Each m In r.Matches(myPage)
Next
TextBox1.Text = mLink
I am getting the error: 'Error 1 Value of type
'System.Text.RegularExpressions.Match' cannot be converted to
'String'.
Can someone help me figure out what I am doing wrong?
I am extremely new to programming so I apologize in advance for my lack
of knowlege, vocabulary and if my code is sloppy. I will take any
suggestions to clean up my code and to follow any best pratices that I
missed. I am taking a stab at writing a program through Visual Basic
2005 Express Edition that will (don't laugh...) keep track, search
through and find new friends with specific interests on myspace. The
functionality of myspace is quite a let down so I thought I would try
to create a program to fill my need. I am stuck at the moment on
trying to do a httpWebRequest and regex to give me an output into a
textbox of friend IDs. Here my code so far that I have figured out
through researching the boards, msdn and using Expresso for my regular
expression:
' Imports System.Text.RegularExpressions
Private Sub GetIDsButton_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles GetIDsButton.Click
Dim myURL As String = ToolStripTextBox1.Text
Dim myReg As Net.HttpWebRequest =
DirectCast(Net.WebRequest.Create(myURL), _
Net.HttpWebRequest)
Dim myResp As Net.HttpWebResponse = _
DirectCast(myReg.GetResponse(), Net.HttpWebResponse)
Dim myStream As IO.Stream = myResp.GetResponseStream()
Dim myreader As New IO.StreamReader(myStream)
Dim myPage As String = myreader.ReadToEnd()
myResp.Close()
'' Regular expression built for Visual Basic on: Thu, Jul 6,
2006, 12:07:39 PM
'' Using Expresso Version: 2.1.2150, http://www.ultrapico.com
''
'' A description of the regular expression:
'' '' [1]: A numbered capture group. [\d{5,9}]
'' Any digit, between 5 and 9 repetitions
'' Match a suffix but exclude it from the capture. ["><img\b]
'' "><img\b
'' "><img
'' First or last character in a word
'
Dim r As Regex = New Regex( _
"(\d{5,9})(?=""><img\b)" + vbCrLf + "", _
RegexOptions.IgnoreCase _
Or RegexOptions.IgnorePatternWhitespace _
)
Dim m As RegularExpressions.Match
Dim mLink As RegularExpressions.Match
For Each m In r.Matches(myPage)
Next
TextBox1.Text = mLink
I am getting the error: 'Error 1 Value of type
'System.Text.RegularExpressions.Match' cannot be converted to
'String'.
Can someone help me figure out what I am doing wrong?