473,395 Members | 1,622 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,395 software developers and data experts.

calculating

lee123
556 512MB
hello it's me again;

i am having a problem with calculating some totals in my project. I have fields on my form that need to be calculated to get a percentage in the end
I wish i could show you what my form looks like but don't know how to. so i will kinda show you this way:

there are 11 textboxes going across the form with lables

textboxnames are as followed

date, neworders,new,used,replacementorders,newcontracts, shortinbundles,total,totalnew,usedtotal,totalperce nt

what i need to calculate is this:

neworders + replacementorders + newcontracts + shortinbundles) in the total

to calculate the percentage i need:

usedtotal / total) in the totalpercent

how can i do this?

lee123
Aug 31 '08 #1
4 1392
lee123
556 512MB
well this is what i have done:

Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2. Private Sub TotalPercent_LostFocus()
  3.     Total.Text = Val(NewOrders.Text) + Val(ReplacementOrders.Text) + Val(Newcontracts.Text) + Val(ShortInBundles.Text)
  4.     TotalPercent.Text = Val(UsedTotal.Text) / Val(Total.Text)
  5.     TotalPercent.Text = FormatPercent(TotalPercent)
  6. End Sub
  7. Private Sub txtNew_LostFocus()
  8.     Dim TotalNew As Integer
  9.     frmQuarterly.TotalNew.Text = txtNew.Text
  10. End Sub
  11. Private Sub Used_LostFocus()
  12.       Dim Used As Integer
  13.     frmQuarterly.Used.Text = totalused.Text
  14. End Sub
  15. Private Sub txtUsed_LostFocus()
  16.  Dim UsedTotal As Integer
  17.  frmQuarterly.UsedTotal.Text = txtUsed.Text
  18. End Sub
but in the percentages i get a weird number, i want whole percentages? instead of 39.28% i would like it to round off to 39.00% or 40.00%.

lee123
Aug 31 '08 #2
MikeTheBike
639 Expert 512MB
well this is what i have done:

Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2. Private Sub TotalPercent_LostFocus()
  3.     Total.Text = Val(NewOrders.Text) + Val(ReplacementOrders.Text) + Val(Newcontracts.Text) + Val(ShortInBundles.Text)
  4.     TotalPercent.Text = Val(UsedTotal.Text) / Val(Total.Text)
  5.     TotalPercent.Text = FormatPercent(TotalPercent)
  6. End Sub
  7. Private Sub txtNew_LostFocus()
  8.     Dim TotalNew As Integer
  9.     frmQuarterly.TotalNew.Text = txtNew.Text
  10. End Sub
  11. Private Sub Used_LostFocus()
  12.       Dim Used As Integer
  13.     frmQuarterly.Used.Text = totalused.Text
  14. End Sub
  15. Private Sub txtUsed_LostFocus()
  16.  Dim UsedTotal As Integer
  17.  frmQuarterly.UsedTotal.Text = txtUsed.Text
  18. End Sub
but in the percentages i get a weird number, i want whole percentages? instead of 39.28% i would like it to round off to 39.00% or 40.00%.

lee123
Hi

You coud try

TotalPercent.Text = FormatPercent(Round(TotalPercent,2))

??

MTB
Sep 1 '08 #3
lee123
556 512MB
hello there MTB or anybody else who reads this post. I have a database in access and i am trying to build the same one in visual basic 6 i have the same fields as i do in the access database but in access you have a event name "continuous form" but in visual basic you don't you have to create you own boxes. so I have done this. each of the text boxes i have mentioned in the previous post stands for 1 week of data i have to fill in so I have put 44 textboxes for each week of a month, 11 textboxes going accross then under them i have 11 more etc. so there is 4 weeks worth (when it's a four week month)

Then after i have filled these with the proper information i have two more textboxes one totals all the percentages and the other should give me the total percent of the whole thing. but i can't get these two text boxes to work right. how can i do this.

lee123
Sep 1 '08 #4
lee123
556 512MB
oops i forgot to add this in the last post. in my access database in the "control source" box i have this code in it:

Expand|Select|Wrap|Line Numbers
  1. =Round(Sum([totalpercent])/Count([date]),2)
how can i do something like this i visual basic. for the total percent of the whole thing

lee123
Sep 1 '08 #5

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

Similar topics

5
by: Ron Adam | last post by:
Hi, I'm having fun learning Python and want to say thanks to everyone here for a great programming language. Below is my first Python program (not my first program) and I'd apreciate any...
0
by: Kasp | last post by:
Hi there, I am trying to make an OLAP cube on a table having two columns (datetime, Number_of_times_an_event_occured). My dimension is time and I want to measure the Min and Max times an event...
1
by: Joe Bongiardina | last post by:
What does the message "calculating...." mean in the lower left status area of a form? I have a form with no calculated, concatenated or lookup fields, yet it displays this msg. The form takes...
1
by: jlm | last post by:
I have a form which feeds table (TblEmpLeave) of Employee Leave Time (time taken off for Administrative, Annual, Sick, Compensation leave). I have EmpID, LeaveDate, LeaveType, LeaveHours fields on...
0
by: robin9876 | last post by:
In an Access 2000 database on some forms 'Calculating...' is continuously displayed in the status bar window and the text of the control is automatically selected. The only workaround is switching...
5
by: sugaray | last post by:
Hi, my problem with calculating the size of an array is when I pass an array as a parameter to a function which perform the calculation, the result never comes right, like below: int...
25
by: Umesh | last post by:
i want to calculate the time required to execute a program. Also i want to calcute the time remaining for the execution of the program. how can i do that? pl mention some good websites for...
1
by: laredotornado | last post by:
Hi, Can anyone recommend a free script for calculating UPS shipping? I am familiar with the script written in 2000 by Jason Costomiris, but UPS is using an XML interface and I wondered if...
4
by: =?Utf-8?B?TmF2YW5lZXRoLksuTg==?= | last post by:
Say I have a class like, class Sample { public decimal first = 10; public decimal second = 20; } I have initialized it
4
by: sumit kale | last post by:
Hi, Can somebody help me resolve my problem ? I am getting error when calculating total using unbound textfiled in subform. I have a main form called purchase_register_master and a subform...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.