|
ASP.Net is a successor to ASP programming. A variety of scripting languages are now available, of which VB remains one option. With this benefit comes the need for some changes.
The following changes are required, to convert ASP to ASPX, still using VB as the scripting language. This is a list of changes I discovered, certainly not an exhaustive list.
This happens when the execution of the code in the web page "falls" into a subroutine, like this:
Line 201:Function getValue(variablename,defaultvalue)
Line 202: dim v
Line 203: v =
Request.Querystring(variablename)
The simplest way to solve this problem is to enclose the functions in "script" tags that run on the server (as opposed to the client, like Javascript)
<script runat="server" language="vb">
function getValue(variablename,devaultvalue)
dim v
v = Request.Querystring(variablename)
...
</script>
It seems that subroutine (i.e. method) calls in VB have changed. The following statement used to be allowed,
Line
239: a1 = a2 + Int((m1-m2)/4+(Rnd()*(m1-m2)*3/4))
Line 240: Response.Write "<p><b>Let's play</b>"
Line 241: Response.Write "<div align=center><center>"
but now the parameter(s) must be enclosed in parentheses, like this:
a1 =
a2 + Int((m1-m2)/4+(Rnd()*(m1-m2)*3/4))
Response.Write("<p><b>Let's
play</b>")
Response.Write("<div align=center><center>")
Line
265: Dim d,d0,d1,d2,d3 ' desired difference
Line 266: d0 = a1-a2
Line
267: d1 = Int((a1+1)*(3-Sqr(5))/2)
Line
268: d2 = Int((a2+1)*(Sqr(5)-1)/2)
Line 269:
d3 = Int((a2+1)*(3-Sqr(5))/2)
Change Sqr to Math.Sqrt:
Dim d,d0,d1,d2,d3 ' desired difference
d0 = a1-a2
d1 = Int((a1+1)*(3-Math.Sqrt(5))/2)
d2 = Int((a2+1)*(Math.Sqrt(5)-1)/2)
d3 = Int((a2+1)*(3-Math.Sqrt(5))/2)
and while you're at it, prefix the following math functions xxx with Math.xxx:
Abs, Round, Pow, Sin, Cos, Tan, Asin, Acos, Atan
"If" blocks were kind of loose in the old VB. A series of statements following "then" were once allowed, but now no longer work.
Line 307: If flag=-1 Then
flag=Int(Rnd()*3) : d=Min(a2,Int(1+3*Math.Abs(Rnd()+Rnd()+Rnd()+Rnd()-2))) : End
If
To put more than one statement after the "then" you must end the "if" statement with the "then" keyword. A single colon accomplishes this:
If
flag=-1 Then : flag=Int(Rnd()*3) :
d=Min(a2,Int(1+3*Math.Abs(Rnd()+Rnd()+Rnd()+Rnd()-2))) : End If
Line 271: If d0<d1 Then : d=d0 :
d0=d1 : d1=d : EndIf
Just change "EndIf" to "End If"
If
d0<d1 Then : d=d0 : d0=d1 : d1=d : End If
The webmaster and author of this Math Help site is Graeme McRae.