how would i write this programme to calculate the average monthly sales figure for a single user like in one calendar year.

A user will be asked to enter 12 sales figures (pounds & pence), one for each month of the year, and then the average monthly figure will be displayed.

you can apply various logics to solve out this.
i am giving you a simple one.

use the inputbox function to display the standard input box and prompt the user to enter a sales figure. to accept 12 values in a continuous manner apply a for...loop statement (for i=1 to 12). you can also perform some validations to check whether the value given by the user is a valid numerals or not but that is completely upto you. take a variable like "sum" and assign zero to it. then while the user enters a sales figure assign that figure to the variable sum and add it with existing value of sum. when 12 figures are accepted divide sum by 12 and store the value (which is your average) to a separate var. like "average" and finally display it.

try it and get back with ur feedback.

regards
Shouvik

bo i didnt manage to make it work can you give me some more depth in code form

ok..... here is the sample
try it and get back with your result

Dim i As Integer, no As Variant, sum As Double, avg As Double, confirm As Integer

sum = 0
avg = 0

For i = 1 To 12 Step 1
begin:
    no = InputBox("Enter sales figure for Month " & i & " :", "Count Avg Sales")
    If Trim(no) <> "" Then
        If IsNumeric(Trim(no)) Then
            sum = sum + no
        Else
            confirm = MsgBox("Not a number." & vbCrLf & "Would you like to retry?", vbQuestion + vbYesNo, _
                    "Type Mismatch")
            If confirm = vbNo Then
                Exit For
            Else
                GoTo begin
            End If
        End If
    Else
        confirm = MsgBox("The figure cannot be null." & vbCrLf & "Would you like to retry?", _
                vbQuestion + vbYesNo, "NULL Input")
        If confirm = vbNo Then
            Exit For
        Else
            GoTo begin
        End If
    End If
Next i

avg = sum / 12
MsgBox "The Avg. sales is " & avg

regards
Shouvik

so how would i to calculate the average sales figure for a team of salespersons in a single month.

so the user will be able to enter a series of sales figures (pounds and pence), one for each salesperson.

The number in the team is not fixed – the user should be able to indicate when they have finished entering all the figures.

so do i have to change the loop statment

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.