Way To Calculate Average
Oct 11, 2009Heres my [code]...
For example if I enter in 45, 45 and 89; I should get 55.75. But instead all I get is 55. How do I get the percentage?
Heres my [code]...
For example if I enter in 45, 45 and 89; I should get 55.75. But instead all I get is 55. How do I get the percentage?
I have text1=a, text2=b, text3=c, text4=d, text5=e
Now I want to calculate the average of the values,
Here's a simple way
average=(a+b+c+d+e)/5
But what if i have values only in 3 textboxes, that means the code will still divide the sum of the values into 5, that will not be correct!
My objective: to check the remaining btns in play and obtain the cash prizes in the remaining btns then calculate the average. It may seem simple but it actually isn't.
Here is what i have so far:
Private Sub btncase1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncase1.Click
If usercase = 0 Then
usercase = btncase1.Text
[CODE]...
I have a spreadsheet that has two columns (A and B) - Column A contains Month/Year and column B contains sales. I would like a bit of vba that will look in column A to find the month/year then calculate from column B the average sales for that period. So for example:
Date Sales
Jan 11 500.00
Jan 11 250.00
Mar 11 152.00
Apr 11 116.00
So in other words there can be a number of lines with the same date/year and the code will need to identify these and average all sales from column B associated with that particular date. I would like the output to appear in a summary table showing the total average sales for each particular month - perhaps this could be output to a new sheet?
I'm in a bit of a pickle. I'm new to Visual Basic and I have been writing a simple program to rate movies. I'm stuck on calculating the average from the text file. The text file holds the numbers from 1 - 10 (ratings). I want my program button to add all the values from the text file and display the average from the total amount of ratings and display them into a text box.
[Code]...
Write a program to calculate the average of three exam marks. The input and output should be done by subprograms GetMarks and DisplayAverage respectively. the calculation should be done by a function, CalcAverage. This is my code:
Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
Dim student As String, exam1 As Integer, exam2 As Integer, exam3 As Integer
Dim average As Double
lstResult.Items.Clear()
[code]....
I'm trying to write a program that allows the user to enter 10 numbers into an input box and then the program will use a function to calculate the average of those numbers. I'm really illiterate when it comes to Visual Basic.
View 2 RepliesI'm looking for a way to calculate an average from a input integer within a loop. When the user enters something like -90, the average will be calculated using the previously input numbers.
View 4 RepliesI want to calculate the average value of excel table readings 1 hr once... how do i import the sheet and how do i calculate the avg in vb.net?
View 4 RepliesThis is the current incarnation of what I have:
'Program: Ch4E4.6
'Programmer: Jeff Pannell
'Date: October 1, 2009
'Description: This will allow for entry of a worker's name and the number of pieces completed. The program will then calculate a pay rate, but also determine an average and summarize number of pieces made, total pay and an average pay per person.
Public Class PieceworkForm
'Declaration of modular-level constants.
Const PIECE_RATEA_Decimal As Decimal = 0.5D
Const PIECE_RATEB_Decimal As Decimal = 0.55D
Const PIECE_RATEC_Decimal As Decimal = 0.6D
[Code] .....
So, my problem is that whenever the form is executed..a user would type in a worker name, and the amount of pieces made. I get a dollar amount earned and then a total pay, though they seem to be the same. More than likely I've got some sort of bad logic in there mathematically.
For my programm I was told to do a programm to calculate the total and average rainfall. I have done so, but now I am supposed to use two function procedures to calculate the total and average rainfall. I can not seem to figure it out and it is very frustrating.
[Code]...
Write a program that reads in a set of grades for a class.The program takes in the number of students in the class from the user. When the Get Grades button is clicked the program then reads in a grade (0-100) for each student using an inputbox. The program should then display the percentage of students who pass and the percentage of students who fail.The program should call a function to calculate the average grade for the class. Then finally the result is then displayed.
Public Function GetPassRate(ByVal intGrade As Integer) As String
Do Until gradeCounter >= NumericUpDown1.Text
If intGrade >= 40 Then[code].......
I'm trying to calculate an average no from data imported from a text file using streamreader. I'm not sure how the loop should read, and the result (average) I want to hold in a separate variable for future use.[code]...
View 1 Repliesi am trying to code a program in vb.net that will calculate the predominant or average colour in an image file and then change the fillcolor of a rectangle to that predominant colour. I want to do that by getting the RGB value of each pixel, adding them up and then dividing them by the total number of pixels in the picture. This is the code that I wrote to do that.
[Code]...
I am a beginner programmer so this is basically the second time I fired up VS (not much experience). I searched the internet for the last hour but found nothing that might help me. I made sure every value is positive and changed all numerical variables from integer to decimal and I still get the error.I have absolutely no idea why this doesnt work but if I remove the "for" loop then the line written in bold works just fine.BTW this is my first post so scuze any mystakes I probably made.
I'm trying to calculate the average hours worked from a set of data imported from a text file using streamreader. My problem is counting the number of entries and the total hours worked imported from a text file within a loop[.
[Code]...
I'm working with an API, for this I'm using this particular call: [URL]
If i use this, I will get all the .price values:
For i = 0 To .bets.Length - 1
With .bets(i)
Print(.price)
End With
Next
Can I calc the average .price value? I will need to sum all the values as well.
Im trying to programme a form to calculate rainfall total,average,maximum, and minimum.how do I create the input box that opens to input the info I cant seem to find it in the tool box. Am i Missing something, and how do I set a array to calculate?
View 2 RepliesI want to include an average in a column where the average ignores zero values in a report cell where the column may have
17
19
0
[code].....
I want 16, not 11 so (17 + 19 + 12 + 13 + 19) / 5 not (17 + 19 + 0 + 0 + 12 + 13 + 19) / 7 Something like this if it would work.
=SUM(Fields!fieldname.Value) / Count(iif(Fields!count_cycle_per_hour.Value >= 0,Fields!fieldname.Value,0))
Essentially just average everything in the column NOT a zero?
I'm working on a function to return a exponential average and there are a lot of examples of exponential moving averages but they all start with a moving average that is just the mean as a lead in to calculating the continuing moving average. I needed just a exponential average of a value set. After Googling my Bing off I still haven't seen anything so here is my attempt at a basic exponential average. Is this correct? Are there any errors? I have seen some text about adding a smoothing value to change the curve of the exponential average but not how that would be implemented.
[Code]...
I put comments on the average output since I kept getting error messages about that. My out keeps saying:
Maximum value: 33
Minimum value: 33
what am I doing wrong?
Option Explicit On
Option Strict On
[Code]...
I'm in a computer science class, and we are writing simple programs using Visual Basic 2008. I am really inept when it comes to this, as I have never done it before. I need to write a program that: "Asks the user for 5 numbers and computes the average. It then displays the average with an appropriate message before the average."
I have been really close with this, but I can't get the numbers to add up, then divide by 5, and display a pop up message.
I am trying to calculate the number of years for my calculate age event handler, however i am apparently missing a method or whatnot because im trying to calculate the age , can anyone suggest help on this. I need to subtract years to get my age but when i try the birthdate.Subtract (currentDate) method i get an error about not able to convert from LONG?
So below is what I have.
Private Sub btnCalculateAge_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculateAge.Click
Dim currentDate As Date
Dim BirthDate As Date
Dim Age As Long
[CODE]
I have a question regarding average and max values. I am new at programming. I have 6 text boxes with generated numbers in them. I need the max number to show up in one text box and the average to show up in the other.Sometimes not all six boxes will be used so I can't just do textbox1 + textbox2 + textbox3 + textbox4 +textbox5 + textbox6 /6 = average and as for max I have no clue how to do that.
View 4 Repliesi am trying to get the average of an array of numbers. There could be up to 999 indexes (I picked a large array because of the the numbers of entries the array could have). As you can see I have managed to get the program to calculate the Sum of the in the array, but I am struggling with getting the average.Say, for example, I enter three sets of 90's, I get 3. How do I get an average?(BTW I have programmed it so the numbers go into an List Box, so this is why you see no code to make up the array or to where the array is printing the values).
Dim Sum As Integer
Dim SumCount As Integer
Dim AverageCount As Integer
[code].....
i need it urgently for this code. i have data input to richtextbox and i want to average up the data? how to do this?
View 6 RepliesHeres my code so far:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Subject As Integer
Subject = InputBox("How many products")
[code]...
Only "0" appears in the TextBox2 and not the average number.
Writing ten(10) input numbers to a text file, and displaying the average in the program, with the two lowest numbers dropped. The project is supposed to allow a user to input 10 number scores and the program will display the average of the scores with the 2 lowest dropped, and write the 10 scores to a text file to display.[code]...
View 9 RepliesWhat is the formula in VB for finding the average of two integers?I know in normal math it is e.g. (4 + 6) / 2 it only needs to be the average of two values.
View 5 RepliesTrying to get the user to put 3 numbers in 3 text boxes and get the average.Private Sub btnAverage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAverage.Click
Dim a As Integer = CInt(txtone.Text)
Dim b As Integer = CInt(txtTwo.Text)
Dim c As Integer = CInt(txtThree.Text)
[code].....
I am working on a project where i need to get the average of 6 numbers i enter in a ListBox. There is one ListBox, one button to get the average, and one label where the average is displayed. i need to use an array and I am using the Visual Basics Programming but i dont think it is that big of a difference.
View 5 Replies