•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the VB.NET section within the Software Development category of DaniWeb, a massive community of 427,205 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,165 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our VB.NET advertiser: Programming Forums
Views: 443 | Replies: 7 | Solved
![]() |
•
•
Join Date: Jul 2007
Posts: 25
Reputation:
Rep Power: 2
Solved Threads: 0
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:
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?
<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?
Last edited by swaters86 : Apr 29th, 2008 at 10:36 am. Reason: fix code tags, fix spelling/grammar mistake
•
•
Join Date: Nov 2007
Location: � Jogja �
Posts: 2,585
Reputation:
Rep Power: 11
Solved Threads: 235
This code running good in desktop application, you can try in web application :
Dim i As Integer
Dim Con As Control
For i = 0 To Me.Controls.Count - 1
Con = Me.Controls(i)
If TypeOf Con Is TextBox Then
Con.Text = 0
End If
Next Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
So, Please do something before post your thread.
* PM Asking will be ignored *
•
•
Join Date: Feb 2008
Posts: 52
Reputation:
Rep Power: 1
Solved Threads: 6
visualbasic Syntax (Toggle Plain Text)
Sum = Val(ExecTextBox.Text * 200) + Val(ManageTextBox.Text * 150) + Val(AssoTextbox.Text * 100)
visualbasic Syntax (Toggle Plain Text)
Sum = Val(ExecTextBox.Text) * 200 + Val(ManageTextBox.Text) * 150 + Val(AssoTextbox.Text) * 100
![]() |
•
•
•
•
•
•
•
•
DaniWeb VB.NET Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
Other Threads in the VB.NET Forum
- Previous Thread: Help with VB.NET Chat Application Interface
- Next Thread: database access



Linear Mode