Help | Site Map
Connecting Tech Pros Worldwide
Reply
 
LinkBack Thread Tools
  #1  
Old August 31st, 2008, 10:24 PM
lee123's Avatar
Needs Regular Fix
 
Join Date: Feb 2007
Location: United States
Age: 37
Posts: 460
Default calculating

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
Reply
  #2  
Old September 1st, 2008, 12:30 AM
lee123's Avatar
Needs Regular Fix
 
Join Date: Feb 2007
Location: United States
Age: 37
Posts: 460
Default

well this is what i have done:

Code:
Option Explicit
Private Sub TotalPercent_LostFocus()
    Total.Text = Val(NewOrders.Text) + Val(ReplacementOrders.Text) + Val(Newcontracts.Text) + Val(ShortInBundles.Text)
    TotalPercent.Text = Val(UsedTotal.Text) / Val(Total.Text)
    TotalPercent.Text = FormatPercent(TotalPercent)
End Sub
Private Sub txtNew_LostFocus()
    Dim TotalNew As Integer
    frmQuarterly.TotalNew.Text = txtNew.Text
End Sub
Private Sub Used_LostFocus()
      Dim Used As Integer
    frmQuarterly.Used.Text = totalused.Text
End Sub
Private Sub txtUsed_LostFocus()
 Dim UsedTotal As Integer
 frmQuarterly.UsedTotal.Text = txtUsed.Text
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
Reply
  #3  
Old September 1st, 2008, 01:03 PM
Expert
 
Join Date: Jun 2007
Location: Derbyshire, UK
Age: 61
Posts: 278
Default

Quote:
Originally Posted by lee123
well this is what i have done:

Code:
Option Explicit
Private Sub TotalPercent_LostFocus()
    Total.Text = Val(NewOrders.Text) + Val(ReplacementOrders.Text) + Val(Newcontracts.Text) + Val(ShortInBundles.Text)
    TotalPercent.Text = Val(UsedTotal.Text) / Val(Total.Text)
    TotalPercent.Text = FormatPercent(TotalPercent)
End Sub
Private Sub txtNew_LostFocus()
    Dim TotalNew As Integer
    frmQuarterly.TotalNew.Text = txtNew.Text
End Sub
Private Sub Used_LostFocus()
      Dim Used As Integer
    frmQuarterly.Used.Text = totalused.Text
End Sub
Private Sub txtUsed_LostFocus()
 Dim UsedTotal As Integer
 frmQuarterly.UsedTotal.Text = txtUsed.Text
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
Reply
  #4  
Old September 1st, 2008, 03:35 PM
lee123's Avatar
Needs Regular Fix
 
Join Date: Feb 2007
Location: United States
Age: 37
Posts: 460
Default

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
Reply
  #5  
Old September 1st, 2008, 03:41 PM
lee123's Avatar
Needs Regular Fix
 
Join Date: Feb 2007
Location: United States
Age: 37
Posts: 460
Default

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:

Code:
=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
Reply
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles