Basically, I'm building a aspx calculator page for a client. What the visitor has to do is fill out the textboxes with a number. it takes the sum of all the text boxes, multiplies the sum by one number to get the minimum value and then another to get the max value and the final result is a string saying "you need at at least min and max sq footage" The code I wrote works perfectly if you give all the text boxes a value, but not if you leave them blank. Here is my code:
<script runat="server">
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
'Declaring varibles
Dim OutputLabel As String
Dim Min As New Integer
Dim Max As New Integer
Dim Sum As New Integer
'Giving variables values
Sum = Val(ExecTextBox.Text * 200) + Val(ManageTextBox.Text * 150) + Val(AssoTextbox.Text * 100)
Min = Sum * 1.1
Max = Sum * 1.35
'Output
OutputLabel = "You will need to search for office space from" & Min & " ft<sup>2</sup>" & " to " & Max & " ft<sup>2</sup>"
Me.lblOutput.Text = OutputLabel
End Sub
</script>
My original code had more textboxes(about 15) but I deleted some them for clarity on here.
What I want to do is set all the textboxes that are left blank to have the automatic value of zero. I think the solution to this is using the If TypeOf Ctrl Is operator but I don't know how to use it. First of all, VS is saying Ctrl isn't declared. is there a namespace for it?
I don't see one used on this page:http://msdn2.microsoft.com/en-us/library/s4zz68xc.aspx
I'm just a webdesigner for this company, I don't' normally do this kinda of coding but I have come a long ways.
ah, i just noticed that msdn page is specific to VS 2008 and .NET 3.5, i'm using VS 2005 with .NET 2.0, will that operator still work?