473,396 Members | 1,812 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

sub total

i need to be able get the subtotals of specific textbox data

how can i say get textbox1 and textbox2 data to add up , or any variance as the user wishes . i have this so far
.
Expand|Select|Wrap|Line Numbers
  1. Function Total(ByVal ddeptprofit() As Double, ByVal ndept As Integer)
  2.  
  3.         Dim dtotal = 0
  4.         Dim i As Integer
  5.         For i = 0 To ndept - 1
  6.  
  7.             ddeptprofit(0) = CDbl(TextBox1.Text)
  8.             dtotal = dtotal + ddeptprofit(i)
  9.         Next
  10.         Return dtotal
  11.     End Function  
  12.  
  13.     Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
  14.  
  15.         Dim ndept = 5
  16.         Dim ddeptprofit(ndept) As Double
  17.         ddeptprofit(0) = CDbl(TextBox1.Text)
  18.  
  19.         ddeptprofit(1) = CDbl(TextBox2.Text)
  20.         ddeptprofit(2) = CDbl(TextBox3.Text)
  21.         ddeptprofit(3) = CDbl(TextBox4.Text)
  22.         ddeptprofit(4) = CDbl(TextBox5.Text)
  23.  
  24.         Dim dtotalprofit As Double
  25.         dtotalprofit = Total(ddeptprofit, ndept)
  26.  
  27.         Label1.Text = "total is" & dtotalprofit.ToString
Nov 23 '09 #1
4 2334
Frinavale
9,735 Expert Mod 8TB
I don't understand something.
You have declared an array of Doubles in your Button1_Click method.

Then you go through all of the TextBoxes, retrieve the values entered by the user, cast them in to Doubles, and then add them to the array of Doubles.

Then you are passing the array of Doubles into the Total method...and for some reason you are setting the first element of this array to the value in TextBox1 while looping through the array.

Expand|Select|Wrap|Line Numbers
  1. Function Total(ByVal ddeptprofit() As Double, ByVal ndept As Integer)
  2.  
  3.         Dim dtotal = 0
  4.         Dim i As Integer
  5.         For i = 0 To ndept - 1
  6.  
  7.             ddeptprofit(0) = CDbl(TextBox1.Text)'<--???
  8.             dtotal = dtotal + ddeptprofit(i)
  9.         Next
  10.         Return dtotal
  11. End Function 
I find this weird but I don't see any reason why this code wouldn't produce the total.

What is the problem?

-Frinny
Nov 23 '09 #2
the problem is i cant get the totals of various text boxs. say i want the subtotal of txtb3 and txtb5 , i think i need to input that i specifically need the subtotal of only these text box's. but i dont know how to . Sorry if their are errors i am still learning . I get the total of all of them, but dont know how to gather variations .
Nov 24 '09 #3
Frinavale
9,735 Expert Mod 8TB
Have you considered placing CheckBoxes next to each TextBox?
Let the user check which TextBoxes they want the total for. Loop through the CheckBoxes to determine which ones were selected and create the sub total for the selected TextBoxes.

-Frinny
Nov 25 '09 #4
how could i do that? the only chckboxs i have used have been in a case select.
Nov 25 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: beavenour | last post by:
I am looking for some help creating a more universal function out of this lame attempt at javascript. I have little experience with javascript and want to be able to universalize this function. ...
4
by: James Greig | last post by:
hello people, i'm just learning javascript, could someone point me in the direction of an example of the following, or give me some clues as to how it might be done: what i would like to do...
10
by: giancarlodirisioster | last post by:
Can someone help me modify this for future Usenet archival and to help me solve what I don't know? <form name="addform" method="POST" action="./submit.php"> <input type="text" name="Box 1"...
2
by: worli | last post by:
Hi All, I have a strange requirement. I have a dynamic input numeric data stream e.g. 2, 2, 4, 5 etc.... ( each input number range from 1 to 10 ). lets take a simple case where all inputs will...
4
by: Rich_C | last post by:
I'm sure this is very simple, but I have very little experience with javascript -- and what I do know isn't helping me here. I have a simple form where users can enter a quantity (qty) and cost...
1
by: CaptainDahlin | last post by:
I know the basics about access reports and putting page totals in the page footers. What I can't figure out is along with the current page total to display the previous page total: At the bottom...
2
by: sammiesue | last post by:
Hi, I have form with 2 autosummed textboxes ("total" and "casinototal"). I would like to have a grand total textbox ("grandtotal") get its value from summing "total" and "casinototal", but it...
6
by: Stuart Shay | last post by:
Hello All: I have a array which contains the totals for each month and from this array I want to get a running total for each month decimal month = new decimal; month = 254; (Jan) month =...
15
klarae99
by: klarae99 | last post by:
I am working on an Inventory Database in Access 2003. I am working on a report that I could print when its time to file our State Sales Tax paperwork. The figures I need for this report are Total...
21
beacon
by: beacon | last post by:
Hello to everybody, I have a section on a form that has 10 questions, numbered 1-10, with 3 option buttons per question. Each of the option buttons have the same response (Yes, No, Don't know),...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.