Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

converting vb to vb.net

Status
Not open for further replies.

onressy

Programmer
Mar 7, 2006
421
CA
Hi i'm converting pages from classic to .net, I'm having issues with this regex aspect and was wondering if someone could help with the compliation error, this is what i have transformed to .net, it starting to faile here: rx=new regexp

Thanks for the pointers!


<%@ Import Namespace="System.Text.RegularExpressions" %>

Code:
<%
Dim x(3)

x(0) = 21
x(1) = 23
x(2) = 25

dim rx,cm,t

's the string in question is a chunck of html

rx=new regexp
rx.global=false
for x = 17 to 31 Step 2

    rx.pattern="^((.|\s)*?\>){" & x & "}((.|\s)*?)\<"

 cm=rx.execute(s)

if cm.count<>0 then
    t=cm(0).submatches(2)
end if

't is the answer
response.write(t)

next
%>

basically i search in the html (s string) for the x array positions of each instance of: >
and getting the valkues between the > this value < of each instance. Hope that makes sense.
 
Any thoughts on this...I have revised the code and now omly get 1 error

Variable 'x' hides a variable in an enclosing block.

for x AS int32 = 17 To 31 Step 2
~

End of statement expected.

rx.Regex("^((.|\s)*?\>){") & x & ("}((.|\s)*?)\<")
~~~~~~~~~~~~~~~~~~~~~~~


Code:
Dim x(3)

x(0) = 21
x(1) = 23
x(2) = 25

dim rx,cm,t

for x AS int32 = 17 To 31 Step 2

    rx.Regex("^((.|\s)*?\>){") & x & ("}((.|\s)*?)\<")

 cm=rx.execute(s)

	if cm.count<>0 then
   	 	t=cm(0).submatches(2)
	end if

response.write(t)

next

't is the answer
response.write(t)
%>
 

Try to throw your scripting knowledge in the trash can. It will kill you going into VB.NET which should not be compared to earlier version of VB other than the name similarity

[sub]____________ signature below ______________
The worst mistake you'll ever make is to do something simply the way you know how while ignoring the way it should be done[/sub]
 
Thanks onpnt, i understand that all var need to have declaration types associated, including arrays. So with that in mind and using the regex snippet, could you give a simple example for me, lets say i have a string like:
Dim s As String
s="<br /><tr><td><font>thisText</font></td></tr>"

and to parse the string for the value after the 4th > and until <, thus parsing the value of thisText

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top