Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

This code give me the error: "BC30616: Variable 'e' hides a variable in an enclosing block" for each of the "Catch e" statements.

 

Am I declaring e incorrectly?

 

<%@ Page Language="vb" %>
<%@ import Namespace="System.Decimal" %>
<script runat="server">

   Sub Page_Load(Source as Object, e as EventArgs)
        Dim decValue1	as Decimal
        Dim decValue2	as Decimal
        Dim strOperator	as String
        Dim decResult 	as Decimal
        decValue1 = Request.QueryString("value1")
        decValue2 = Request.QueryString("value2")
        strOperator = Request.QueryString("operator")
        Try
        Select Case strOperator
                Case "multiply"
                    decResult = MultiplyValues(decValue1, decValue2)
                Case "divide"
                    decResult = DivideValues(decValue1, decValue2)
                Case "add"
                    decResult = AddValues(decValue1, decValue2)
                Case "Subtract"
                    decResult = SubtractValues(decValue1, decValue2)
        End Select
        Catch e as OverflowException
        response.write("The result was too large to represent as a decimal.")
        Catch e as dividebyzeroexception
        response.write("You can't divide by zero!")
        Finally
        Response.Write("The result of your calculation is: " & decResult)
        end try
   end sub
   
   Function MultiplyValues(decValue1 as decimal, DecValue2 as Decimal)
   Dim decResult as Decimal
        decResult = Multiply(decValue1, decValue2)
        Return decResult
   End function
   
   Function DivideValues(decValue1 as decimal, DecValue2 as Decimal)
   Dim decResult as Decimal
        decResult = Divide(decValue1, decValue2)
        Return decResult
   End function
   
   Function AddValues(decValue1 as decimal, DecValue2 as Decimal)
   Dim decResult as Decimal
        decResult = Add(decValue1, decValue2)
        Return decResult
   End function
   
   Function SubtractValues(decValue1 as decimal, DecValue2 as Decimal)
   Dim decResult as Decimal
        decResult = Subtract(decValue1, decValue2)
        Return decResult
   End function

</script>
<html>
<head>
</head>
<body>
</body>
</html>

 

Thanks!

Read the Fovean Chronicles

Because you just can't spend your whole day programming!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...