473,778 Members | 1,958 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

calculating

lee123
556 Contributor
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,u sed,replacement orders,newcontr acts,shortinbun dles,total,tota lnew,usedtotal, totalpercent

what i need to calculate is this:

neworders + replacementorde rs + 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 1409
lee123
556 Contributor
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 Recognized Expert Contributor
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.Te xt = FormatPercent(R ound(TotalPerce nt,2))

??

MTB
Sep 1 '08 #3
lee123
556 Contributor
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 Contributor
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
8807
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 feedback on how I might do things differently to make it either more consice, readable, or faster. ie... are there better ways to do it in Python? It won't break any records for calculating pi, that wasn't my goal, learning Python was. But it might...
0
2273
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 occured over time. I have no problem in calculating Maximum occurance of events over time. However, I have some NULL values in my Number_of_times_an_event_occured column, due to which I don't see any result when I try to calculate
1
3351
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 forever to open and I'm wondering what it's "calculating" and if that's the bottleneck. Thanks.
1
2380
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 this form. Any employee can have multiple entries in the table (key fields are EmpID and LeaveID) for multiple dates (John Doe can take 3 days annual leave, then take 3 days sick leave in any given month. I have a BeginningBalance of hours that...
0
1788
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 to another application and back between each field that data is entered. I have tried this database on pc's that have office 2000 SP1a and SP3. How do investigate what is causing this calculating issue and how do I resolve it?
5
11953
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 SizeOfArray(int a) { return (sizeof(a)/sizeof(a)); } main() { int a={1,2,3}; printf("%d\n",SizeOfArray(a));
25
5028
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 learning advanced C.thx.
1
2424
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 there's anything more updated. The pages I located on Google turned up broken links. Thanks, - Dave
4
2091
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
4033
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 called purchase_register_details, In sub form i have a unbound textfield called txt_Total_Amount where in i am calculating total amount for different items purchased by giving following code in control source. ContolSource: =Sum() In my main form i...
0
9629
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10298
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10127
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10069
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9923
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8957
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5370
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3627
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2865
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.