heb de volgende code die iemand ooit voor me gemaakt heeft ,maar er doet zich een klein probleem voor . het werkt opzichzelf perfect alleeen alles word afgerond op 0,00 dus bv 150+150+150+149=599/4=149.75 de uitkomst die ik krijg is 150.00 en dat moet dus niet ,wat is hier fout
Option Explicit
Dim m_intScores(0 To 11) As Integer
Private Sub cmdAverage_Click()
On Error GoTo ErrHandler
Dim intSheetCounter As Integer
Dim intNumberSheetCounter As Integer
Dim intRow As Integer
Dim intColumn As Integer
Dim intNumberOfGames As Integer
Dim intGames As Integer
Dim intCounter As Integer
Dim intScore As Integer
'Number of sheets
intNumberSheetCounter = Application.Sheets.Count
intGames = 4
For intSheetCounter = 1 To intNumberSheetCounter
'Goto sheet
Application.Sheets(intSheetCounter).Activate
intRow = 7
intNumberOfGames = 0
Do
intColumn = 3
If CInt(Application.Cells(intRow, 3)) > 0 Then
For intCounter = 1 To intGames
If CInt(Application.Cells(intRow, intColumn)) > 0 Then
intScore = intScore + CInt(Application.Cells(intRow, intColumn))
intNumberOfGames = intNumberOfGames + 1
End If
intColumn = intColumn + 1
Next
End If
If intScore > 0 Then
Application.Cells(intRow,
= Average(intScore, intNumberOfGames)
Else
Application.Cells(intRow,
= 0
End If
intScore = 0
intNumberOfGames = 0
intRow = intRow + 1
'Loop until empty cell
Loop Until Application.Cells(intRow, 2) = ""
Next
ReturnSheet
Exit Sub
ErrHandler:
MsgBox "Fout opgetreden in bereken gemiddelde!", vbCritical, "Bowling scores"
End Sub
Option Explicit
Dim m_intScores(0 To 11) As Integer
Private Sub cmdAverage_Click()
On Error GoTo ErrHandler
Dim intSheetCounter As Integer
Dim intNumberSheetCounter As Integer
Dim intRow As Integer
Dim intColumn As Integer
Dim intNumberOfGames As Integer
Dim intGames As Integer
Dim intCounter As Integer
Dim intScore As Integer
'Number of sheets
intNumberSheetCounter = Application.Sheets.Count
intGames = 4
For intSheetCounter = 1 To intNumberSheetCounter
'Goto sheet
Application.Sheets(intSheetCounter).Activate
intRow = 7
intNumberOfGames = 0
Do
intColumn = 3
If CInt(Application.Cells(intRow, 3)) > 0 Then
For intCounter = 1 To intGames
If CInt(Application.Cells(intRow, intColumn)) > 0 Then
intScore = intScore + CInt(Application.Cells(intRow, intColumn))
intNumberOfGames = intNumberOfGames + 1
End If
intColumn = intColumn + 1
Next
End If
If intScore > 0 Then
Application.Cells(intRow,
Else
Application.Cells(intRow,
End If
intScore = 0
intNumberOfGames = 0
intRow = intRow + 1
'Loop until empty cell
Loop Until Application.Cells(intRow, 2) = ""
Next
ReturnSheet
Exit Sub
ErrHandler:
MsgBox "Fout opgetreden in bereken gemiddelde!", vbCritical, "Bowling scores"
End Sub