Showing posts with label statement. Show all posts
Showing posts with label statement. Show all posts

Saturday, March 31, 2012

subroutines or functions wont work.

any time i try coding a function or a subrouting the page won't run. iget error msg: BC30289: Statement cannot appear within a method body. End of method assumed.

here's my code. PLEASE HELP!, what am i typing wrong??
<%@dotnet.itags.org. Page Language="VB" %>
<script runat="server"
' Insert page code here
'

</script>
<html>
<head>
</head>
<body>
<form runat="server">
<%
Dim arrPrimeNos, arrNames
Sub subPrintArray(arrToPrint, iStartValue, iStopValue)
Dim iCounter
For iCounter = iStartValue to iStopValue
Response.Write(arrToPrint(iCounter))
Response.Write("<BR>")
Next
End Sub
arrPrimeNos=Array(2,3,5)
arrName=Array("John","Mary","Bolek")

'call subroutine
subPrintArray arrNames, 2, 3
%
</form>
</body>
</html>1. You'd better put the server side code in <script> tag if you use inline coding. Using <% %> is not a .net way.

2. You can only call a method (function, subrouting or event handler) from a method (function, subrouting or event handler), so your code need to change like this:


<%@. Page Language="VB" %>
<script runat="server"
Sub page_load

Dim arrPrimeNos() As Integer = {2, 3, 5}
Dim arrNames() As String = {"John", "Mary", "Bolek"}

'call subroutine
subPrintArray arrNames, 2, 3
End Sub

Sub subPrintArray(arrToPrint, iStartValue, iStopValue)
Dim iCounter
For iCounter = iStartValue to iStopValue
Response.Write(arrToPrint(iCounter))
Response.Write("<BR>")
Next
End Sub

</script>
<html>
<head>
</head>
<body>
<form runat="server">
</form>
</body>
</html>


thank you very much

Monday, March 26, 2012

Suggestions for "For ... Next"

Hi,

I never used the For...Next Statement.

Can someone give me some suggestions how i can use it with this code to simplify it

Thanks in advance
------------------

If TotalPagesInteger < 8 Then
If TotalPagesInteger = 1 Then
LinkPage_1.Visible = True
LinkPage_1.Text = "1"
ElseIf TotalPagesInteger = 2 Then
LinkPage_1.Visible = True
LinkPage_2.Visible = True
LinkPage_1.Text = "1"
LinkPage_2.Text = "2"
ElseIf TotalPagesInteger = 3 Then
LinkPage_1.Visible = True
LinkPage_2.Visible = True
LinkPage_3.Visible = True
LinkPage_1.Text = "1"
LinkPage_2.Text = "2"
LinkPage_3.Text = "3"
ElseIf TotalPagesInteger = 4 Then
LinkPage_1.Visible = True
LinkPage_2.Visible = True
LinkPage_3.Visible = True
LinkPage_4.Visible = True
LinkPage_1.Text = "1"
LinkPage_2.Text = "2"
LinkPage_3.Text = "3"
LinkPage_4.Text = "4"
ElseIf TotalPagesInteger = 5 Then
LinkPage_1.Visible = True
LinkPage_2.Visible = True
LinkPage_3.Visible = True
LinkPage_4.Visible = True
LinkPage_5.Visible = True
LinkPage_1.Text = "1"
LinkPage_2.Text = "2"
LinkPage_3.Text = "3"
LinkPage_4.Text = "4"
LinkPage_5.Text = "5"
ElseIf TotalPagesInteger = 6 Then
LinkPage_1.Visible = True
LinkPage_2.Visible = True
LinkPage_3.Visible = True
LinkPage_4.Visible = True
LinkPage_5.Visible = True
LinkPage_6.Visible = True
LinkPage_1.Text = "1"
LinkPage_2.Text = "2"
LinkPage_3.Text = "3"
LinkPage_4.Text = "4"
LinkPage_5.Text = "5"
LinkPage_6.Text = "6"
ElseIf TotalPagesInteger = 7 Then
LinkPage_1.Visible = True
LinkPage_2.Visible = True
LinkPage_3.Visible = True
LinkPage_4.Visible = True
LinkPage_5.Visible = True
LinkPage_6.Visible = True
LinkPage_7.Visible = True
LinkPage_1.Text = "1"
LinkPage_2.Text = "2"
LinkPage_3.Text = "3"
LinkPage_4.Text = "4"
LinkPage_5.Text = "5"
LinkPage_6.Text = "6"
LinkPage_7.Text = "7"
End If
End If

Hi, I think I'd use a Select Case statement for this. Something like:

Select Case TotalPagesInteger
Case 1
LinkPage_1.Visible =True
LinkPage_1.Text ="1"
Case 2
LinkPage_1.Visible =True
LinkPage_2.Visible =True
LinkPage_1.Text ="1"
LinkPage_2.Text ="2"
Case 3
LinkPage_1.Visible =True
LinkPage_2.Visible =True
LinkPage_3.Visible =True
LinkPage_1.Text ="1"
LinkPage_2.Text ="2"
LinkPage_3.Text ="3"
Case 4
... more code
End Select


Hello my friend,

Use the following: -

If TotalPagesInteger < 8 Then
For i As Integer = 1 To 7
If i <= TotalPagesInteger Then
Dim lnk As HyperLink = DirectCast(Me.FindControl("LinkPage_" & i), HyperLink)
lnk.Visible = True
lnk.Text = i
End If
Next
End If


I assumed that LinkPage_1, LinkPage_2, etc are hyperlinks. If not, just change HyperLink in the code to whatever the controls are.


Kind regards

Scotty


Humm,

I tried it and it gives me this error :

Object reference not set to an instance of an object.

Description:An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details:System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 231: If i <= TotalPagesInteger ThenLine 232: Dim lnk As HyperLink = DirectCast(Me.FindControl("LinkPage_" & i), HyperLink)Line 233: lnk.Visible = TrueLine 234: lnk.Text = iLine 235: End If


Hi,

This error message tells you, it could not find control of LinkPage_1(or LinkPage_2, LinkPage_3 etc.) in the page, you should check whether there are the LinkPages' id in the page.


Im sure that is theDirectCast that is wrong.

Can somebody help?


This should help you out. I think that this is what you are looking for.

Dim outIdx as Integer

If TotalPagesInteger < 8 Then
For outIdx = 1 to TotalPagesInteger
Dim hlink As HyperLink = DirectCast(Me.FindControl("LinkPage_" & outIdx), HyperLink)
hlink.Visible = True
hlink.Text = inIdx.ToString
Next
End If

Basically you are wanting to go from 1 to the TotalPagesInteger and make all the previous links visible and the text to be the number of the page.

Ben Miller


Nope

Didn't work too!

I got the same error and LinkPage_1 to LinkPage_7 exists in my code...

Any idea?


I am totally sorry. I got sidetracked using the FindControl. This only works if they are rendered on the page, so I went back to look at your coding and I now understand what you want.

You could so something like this then to take advantage of the For loop.

Dim aryList as ArrayList = new ArrayList()

aryList.Add(LinkPage_1)
aryList.Add(LinkPage_2)
aryList.Add(LinkPage_3)
aryList.Add(LinkPage_4)
aryList.Add(LinkPage_5)
aryList.Add(LinkPage_6)
aryList.Add(LinkPage_7)

Dim outIdx as Integer

If TotalPagesInteger < 8 Then
For outIdx = 1 to TotalPagesInteger
Dim hlink As HyperLink = DirectCast(aryList[outIdx-1], HyperLink)
hlink.Visible = True
hlink.Text = inIdx.ToString
Next
End If

That should do it. Sorry for the delay.

Ben Miller


Hi,

Thanks!!!

Here is the working code :
------------
Dim aryList As ArrayList = New ArrayList()
aryList.Add(LinkPage_1)
aryList.Add(LinkPage_2)
aryList.Add(LinkPage_3)
aryList.Add(LinkPage_4)
aryList.Add(LinkPage_5)
aryList.Add(LinkPage_6)
aryList.Add(LinkPage_7)

Dim outIdx As Integer
Dim hlink As HyperLink

If TotalPagesInteger < 8 Then
For outIdx = 1 To TotalPagesInteger
hlink = DirectCast(aryList(outIdx - 1), HyperLink)
hlink.Visible = True
hlink.Text = outIdx.ToString
Next
End If

Tuesday, March 13, 2012

switch

Hi
Is it possible to replace this if statement by a switch?
private int doCalculation(int lhs, int rhs)
{
int result = 0;

if (addition.Checked)
result = addValues(lhs, rhs);
else if (subtraction.Checked)
result = subtractValues(lhs, rhs);
else if (multiplication.Checked)
result = multiplyValues(lhs, rhs);
else if (division.Checked)
result = divideValues(lhs, rhs);
else if (remainder.Checked)
result = remainderValues(lhs, rhs);

return result;
}

thanksI'm afraid not. You could use a ternary operator instead, but you're essentially doing the same thing as the if statements:

private int doCalculation(int lhs, int rhs)
{
return (addition.Checked) ? addValues(lhs, rhs) :
(subtraction.Checked) ? subtractValues(lhs, rhs) :
(multiplication.Checked) ? multiplyValues(lhs, rhs) :
(division.Checked) ? divideValues(lhs, rhs) :
(remainder.Checked) ? remainderValues(lhs, rhs) : 0;
}

i don't think so in C#

the shared thing in these Values is true Value
so, you will use it to compare it by all checked value for RadioButtons But C# Dont Agree but in case CONSTANT it agree for values only

But in VB.NET You Can Do That


Select Case True
Case addition.Checked

Case subtraction.Checked

Case multiplication.Checked

Case division.Checked

Case remainder.Checked

End Select


I can't either find out an answer because I think each if statement tests a different condition.

thanks for comments

Switch / case statements

Been a while since I did a switch statement, and that was in VB.
Error I'm getting is...
Control cannot fall through from one case label ('case 14:') to another
Well, not just case 14, but all of them.
Here's the sample...

publicbool checkMe(ArrayList myArray,int myInt){

switch (myInt) {

case 3 :

if(System.Convert.ToInt32( myArray[0] )== 0 &&

System.Convert.ToInt32( myArray[1]) == 1 )

{

myArray[1] = 0;

myArray[3] = 0;

myArray[0] = 1;

pNum = 3;

tempAL = myArray;

printArray(tempAL);

bSuccess =true;

break;

}

if( System.Convert.ToInt32( myArray[5] ) == 0 &&

System.Convert.ToInt32( myArray[4] ) == 1 )

{

myArray[4] = 0;

myArray[3] = 0;

myArray[5] = 1;

pNum = 3;

tempAL = myArray;

printArray(tempAL);

bSuccess =true;

break;

}

case 5 :

if( System.Convert.ToInt32( myArray[0] ) == 0 &&

System.Convert.ToInt32( myArray[2] ) == 1 )

{

myArray[2] = 0;

myArray[5] = 0;

myArray[0] = 1;

pNum = 5;

tempAL = myArray;

printArray(tempAL);

bSuccess =true;

break;

}

if( System.Convert.ToInt32( myArray[3] ) == 0 &&

System.Convert.ToInt32( myArray[4] ) == 1 )

{

myArray[4] = 0;

myArray[5] = 0;

myArray[3] = 1;

pNum = 5;

tempAL = myArray;

printArray(tempAL);

bSuccess =true;

break;

}

default :

{

bSuccess =false;

}


}

So, what's the deal?
Thanks,
Zath

That's because C# requires a break statement after every case statement (at least ones with code in them), and yours are within conditionals. Here's your code fixed up:
public bool checkMe(ArrayList myArray, int myInt)
{
switch ( myInt )
{
case 3:
if ( System.Convert.ToInt32(myArray[0]) == 0 &&
System.Convert.ToInt32(myArray[1]) == 1 )
{
myArray[1] = 0;
myArray[3] = 0;
myArray[0] = 1;

pNum = 3;
tempAL = myArray;
printArray(tempAL);

bSuccess = true;
break;
}

if ( System.Convert.ToInt32(myArray[5]) == 0 &&
System.Convert.ToInt32(myArray[4]) == 1 )
{
myArray[4] = 0;
myArray[3] = 0;
myArray[5] = 1;

pNum = 3;
tempAL = myArray;
printArray(tempAL);

bSuccess = true;

break;
}

break;
case 5:
if ( System.Convert.ToInt32(myArray[0]) == 0 &&
System.Convert.ToInt32(myArray[2]) == 1 )
{
myArray[2] = 0;
myArray[5] = 0;
myArray[0] = 1;

pNum = 5;
tempAL = myArray;
printArray(tempAL);

bSuccess = true;

break;
}


if ( System.Convert.ToInt32(myArray[3]) == 0 &&
System.Convert.ToInt32(myArray[4]) == 1 )

{
myArray[4] = 0;
myArray[5] = 0;
myArray[3] = 1;

pNum = 5;
tempAL = myArray;
printArray(tempAL);
bSuccess = true;

break;
}

break;
default :
bSuccess = false;

break;
} // end of switch statement
} // end of method


You could do something like this and it would work:
switch ( someValue )
{
case 0:
case 1:
// do something
break;
case 2:
// do something
break;
default:
break;
}
NC...


Thanks, that did the trick.
Just when you think you know all the syntaxBig Smile [:D]
Zath

switch case with enum

Hi

i am getting "a constant value is required" error when i use the enum value
in case statement/
Any ideas?

sample code:

myconfig.cs
----
public enum WebHostingTypes
{

[Description("BASIC")] Basic,

[Description("PLUS")] Plus,

[Description("PREM")] Premium

}

product.cs
------

switch(WebHostingType)

{

case objCommon.GetEnumValueDescription(myconfig.WebHost ingTypes.Basic):
break;

case ....

}

----------

Even if i tried using a something like

public enum Volume

{

Low,

Medium,

High

}

string myVolume = "Medium";

switch(myVolume)

{

case myconfig.Volume.Medium:
break;

case ....

}

- GaneEnumerated values are numbers. If you treat them as such you will have no
problems with them.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.

"gane kol" <ganekol@.softca.com> wrote in message
news:OY%23kHOlUFHA.1404@.TK2MSFTNGP09.phx.gbl...
> Hi
> i am getting "a constant value is required" error when i use the enum
> value
> in case statement/
> Any ideas?
> sample code:
> myconfig.cs
> ----
> public enum WebHostingTypes
> {
> [Description("BASIC")] Basic,
> [Description("PLUS")] Plus,
> [Description("PREM")] Premium
> }
> product.cs
> ------
> switch(WebHostingType)
> {
> case objCommon.GetEnumValueDescription(myconfig.WebHost ingTypes.Basic):
> break;
> case ....
> }
> ----------
> Even if i tried using a something like
> public enum Volume
> {
> Low,
> Medium,
> High
> }
> string myVolume = "Medium";
> switch(myVolume)
> {
> case myconfig.Volume.Medium:
> break;
> case ....
> }
> - Gane
well, ok. But i couldnt figure why the example below (2nd Example) is not
working for me, but worked for others (found in some tech articles).

"Kevin Spencer" <kevin@.DIESPAMMERSDIEtakempis.com> wrote in message
news:eq2zl2lUFHA.3596@.TK2MSFTNGP14.phx.gbl...
> Enumerated values are numbers. If you treat them as such you will have no
> problems with them.
> --
> HTH,
> Kevin Spencer
> Microsoft MVP
> .Net Developer
> What You Seek Is What You Get.
> "gane kol" <ganekol@.softca.com> wrote in message
> news:OY%23kHOlUFHA.1404@.TK2MSFTNGP09.phx.gbl...
> > Hi
> > i am getting "a constant value is required" error when i use the enum
> > value
> > in case statement/
> > Any ideas?
> > sample code:
> > myconfig.cs
> > ----
> > public enum WebHostingTypes
> > {
> > [Description("BASIC")] Basic,
> > [Description("PLUS")] Plus,
> > [Description("PREM")] Premium
> > }
> > product.cs
> > ------
> > switch(WebHostingType)
> > {
> > case objCommon.GetEnumValueDescription(myconfig.WebHost ingTypes.Basic):
> > break;
> > case ....
> > }
> > ----------

*********************** 2ND EXAMPLE

> > Even if i tried using a something like
> > public enum Volume
> > {
> > Low,
> > Medium,
> > High
> > }
> > string myVolume = "Medium";
> > switch(myVolume)
> > {
> > case myconfig.Volume.Medium:
> > break;
> > case ....
> > }
> > - Gane
> well, ok. But i couldnt figure why the example below (2nd Example) is not
> working for me, but worked for others (found in some tech articles).

I wouldn't know, as I haven't seen them. However, I can't see any good
reason for doing so. You have to be careful what tech articles you read, and
by whom they are written.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.

"gane kol" <ganekol@.softca.com> wrote in message
news:umQZaHmUFHA.3280@.TK2MSFTNGP10.phx.gbl...
> well, ok. But i couldnt figure why the example below (2nd Example) is not
> working for me, but worked for others (found in some tech articles).
>
> "Kevin Spencer" <kevin@.DIESPAMMERSDIEtakempis.com> wrote in message
> news:eq2zl2lUFHA.3596@.TK2MSFTNGP14.phx.gbl...
>> Enumerated values are numbers. If you treat them as such you will have no
>> problems with them.
>>
>> --
>> HTH,
>>
>> Kevin Spencer
>> Microsoft MVP
>> .Net Developer
>> What You Seek Is What You Get.
>>
>> "gane kol" <ganekol@.softca.com> wrote in message
>> news:OY%23kHOlUFHA.1404@.TK2MSFTNGP09.phx.gbl...
>> > Hi
>>> > i am getting "a constant value is required" error when i use the enum
>> > value
>> > in case statement/
>> > Any ideas?
>>> > sample code:
>>> > myconfig.cs
>> > ----
>> > public enum WebHostingTypes
>> > {
>>> > [Description("BASIC")] Basic,
>>> > [Description("PLUS")] Plus,
>>> > [Description("PREM")] Premium
>>> > }
>>> > product.cs
>> > ------
>>> > switch(WebHostingType)
>>> > {
>>> > case objCommon.GetEnumValueDescription(myconfig.WebHost ingTypes.Basic):
>> > break;
>>> > case ....
>>> > }
>>> > ----------
>>
>
> *********************** 2ND EXAMPLE
>> > Even if i tried using a something like
>>> > public enum Volume
>>> > {
>>> > Low,
>>> > Medium,
>>> > High
>>> > }
>>> > string myVolume = "Medium";
>>> > switch(myVolume)
>>> > {
>>> > case myconfig.Volume.Medium:
>> > break;
>>> > case ....
>>> > }
>>> > - Gane
>>>>
>>

switch case with enum

Hi
i am getting "a constant value is required" error when i use the enum value
in case statement/
Any ideas?
sample code:
myconfig.cs
--
public enum WebHostingTypes
{
[Description("BASIC")] Basic,
[Description("PLUS")] Plus,
[Description("PREM")] Premium
}
product.cs
--
switch(WebHostingType)
{
case objCommon.GetEnumValueDescription(myconfig.WebHostingTypes.Basic):
break;
case ....
}
Even if i tried using a something like
public enum Volume
{
Low,
Medium,
High
}
string myVolume = "Medium";
switch(myVolume)
{
case myconfig.Volume.Medium:
break;
case ....
}
- GaneEnumerated values are numbers. If you treat them as such you will have no
problems with them.
HTH,
Kevin Spencer
Microsoft MVP
.Net Developer
What You S Is What You Get.
"gane kol" <ganekol@.softca.com> wrote in message
news:OY%23kHOlUFHA.1404@.TK2MSFTNGP09.phx.gbl...
> Hi
> i am getting "a constant value is required" error when i use the enum
> value
> in case statement/
> Any ideas?
> sample code:
> myconfig.cs
> --
> public enum WebHostingTypes
> {
> [Description("BASIC")] Basic,
> [Description("PLUS")] Plus,
> [Description("PREM")] Premium
> }
> product.cs
> --
> switch(WebHostingType)
> {
> case objCommon.GetEnumValueDescription(myconfig.WebHostingTypes.Basic):
> break;
> case ....
> }
> --
> Even if i tried using a something like
> public enum Volume
> {
> Low,
> Medium,
> High
> }
> string myVolume = "Medium";
> switch(myVolume)
> {
> case myconfig.Volume.Medium:
> break;
> case ....
> }
> - Gane
>
well, ok. But i couldnt figure why the example below (2nd Example) is not
working for me, but worked for others (found in some tech articles).
"Kevin Spencer" <kevin@.DIESPAMMERSDIEtakempis.com> wrote in message
news:eq2zl2lUFHA.3596@.TK2MSFTNGP14.phx.gbl...
> Enumerated values are numbers. If you treat them as such you will have no
> problems with them.
> --
> HTH,
> Kevin Spencer
> Microsoft MVP
> .Net Developer
> What You S Is What You Get.
> "gane kol" <ganekol@.softca.com> wrote in message
> news:OY%23kHOlUFHA.1404@.TK2MSFTNGP09.phx.gbl...
*********************** 2ND EXAMPLE
>
> well, ok. But i couldnt figure why the example below (2nd Example) is not
> working for me, but worked for others (found in some tech articles).
I wouldn't know, as I haven't seen them. However, I can't see any good
reason for doing so. You have to be careful what tech articles you read, and
by whom they are written.
HTH,
Kevin Spencer
Microsoft MVP
.Net Developer
What You S Is What You Get.
"gane kol" <ganekol@.softca.com> wrote in message
news:umQZaHmUFHA.3280@.TK2MSFTNGP10.phx.gbl...
> well, ok. But i couldnt figure why the example below (2nd Example) is not
> working for me, but worked for others (found in some tech articles).
>
> "Kevin Spencer" <kevin@.DIESPAMMERSDIEtakempis.com> wrote in message
> news:eq2zl2lUFHA.3596@.TK2MSFTNGP14.phx.gbl...
>
>
> *********************** 2ND EXAMPLE
>
>

switch statement

I have the following switch statement and am getting the error:
not all code paths return a value
I am not seeing why.

publicbool checkNewMove(ArrayList myArray,int myInt)

{

switch (myInt)

{

case 4 :

if( System.Convert.ToInt32( myArray[13] ) == 0 &&

System.Convert.ToInt32( myArrayMusic [8] ) == 1 )

{

myArrayMusic [8] = 0;

myArray[4] = 0;

myArray[13] = 1;

pNum = 4;

tempAL = myArray;

printArray(tempAL);

bSuccess =true;

break;

}

break;

default :

{

bSuccess =false;

//return bSuccess;

break;

}

//break;

}// end switch


}
Suggestions?
Thanks,
ZathI have added the line you are missing in red

publicbool checkNewMove(ArrayList myArray,int myInt)
{
switch (myInt)
{
case 4 :
if( System.Convert.ToInt32( myArray[13] ) == 0 &&
System.Convert.ToInt32( myArray[WhateverNumberThisIsSupposedToBe] ) == 1 )
{
myArray[WhateverNumberThisIsSupposedToBe] = 0;
myArray[4] = 0;
myArray[13] = 1;
pNum = 4;
tempAL = myArray;
printArray(tempAL);
bSuccess =true;
break;
}
break;
default :
{
bSuccess =false;
//return bSuccess;
break;
}
}// end switch
return bSuccess; [EDIT]
}


Thanks. don't know why I didn't see that. I have written many functions that need a return.
Must have been I was looking too hard at the switch.
Zath

switch statement error?

This is my first application so be gentle. :) I'm using WebMatrix.
I have the following code in index.aspx

<script runat="server">
switch(Request.QueryString["page"]) {
case "products":
masterForm.Controls.Add(LoadControl("products.ascx"));
break;
}
</script
masterForm is the id of the form tag in index.aspx

I am basically trying to dynamically include each section and use index.aspx as the master template file.

Here's the error:
Compiler Error Message: CS1519: Invalid token 'switch' in class, struct, or interface member declaration

It's stopping on the line with the switch statement.

What am I doing wrong?what is "page" in the following code

switch(Request.QueryString["page"])


page is supposed to be coming from:

index.aspx?page=products
ok I think the problem is that you are declaring switch in the HTML View. You need to run this code in the code behind file where all the Page_Load and Page_Init methods are. I hope you understand what I am trying to say.
Thanks, that did it!


<script runat="server">
void Page_Load() {
switch(Request.QueryString["page"]) {
case "products":
masterForm.Controls.Add(LoadControl("products.ascx"));
break;
}
}
</script>

Mohammed, WebMatrix doesn't permit the use of CodeBehind.

grizjr, you need to place the switch in the Page_Load method. For example:

 void Page_Load(Object Sender, EventArgs E) {

switch (...) {
...
}
}

Obviously you've decided against my suggestion of simplifying your code.
The code is not working properly.
<script runat="server">

void Page_Load() {

switch(Request.QueryString["page"]) {

case "products":

masterForm.Controls.Add(LoadControl("products.ascx"));

break;

}

}

</script>
When I try and run it: I get this message:

Active Server Pages-Error 'ASP 0124'

Missing Language attribute

/nbhs/control-panel/switch.asp, line 2

The required Language attribute of the script tag is missing.

Active Server Pages-Error 'ASP 0124'


What tag is it missing?Tongue Tied [:S]


Now that problem is fixed with this line of code:
<script language="vbscript" runat="server">
I just needed to add language="vbscript"
now I get another problem
This is the code that I have:
<script language="vbscript" runat="server">

void Page_Load(Object Sender, EventArgs E) {
switch(Request.QueryString["page"]) {

case "products":

masterForm.Controls.Add(LoadControl("products.ascx"));

break;

}

}

</script>

The error that I get is this:


Microsoft VBScript compilation error-Error '800a03ee'

Expected ')'

/nbhs/control-panel/switch.asp, line 5

void Page_Load(Object Sender, EventArgs E) {
--------^

How can I fix this?


switch statement less than ? more than ?

switch (Drivers) {case < 2:break;case >5:break;default: Console.WriteLine("Default case"); }
Can I use less than or more than in switch statement

like this

You cannot do this in C#, it's by design:http://msdn2.microsoft.com/en-us/vcsharp/aa336815.aspx

VB.NET can handle this though.


unfortunately no. you can do something like

case 1:

case 2:

do something;

break;

but < and > don't work