Hi people, I'm doing a first year university course on VB6.
I need some help with my code. I am getting runtime error 13, type mismatch, its a really simple assignment but because my
VB is a student version, I wasn't able to find out what the mismatch is and how to fix it.
This is supposed to just allow you to enter a value, when you click next, it adds the value from whatever was there before to make a new sum. It also shows count or number (how many values have been entered) and also average, the sum divided by count or number. When clear is clicked, it should clear everything.
Code:
Option Explicit
Private Sum As Double
Private Number As Integer
Private Sub cmdClear_Click()
Sum = 0
Number = 0
txtValue.Text = vbNullString
txtCount.Text = vbNullString
txtSum.Text = vbNullString
txtAverage.Text = vbNullString
txtValue.SetFocus
End Sub
Private Sub cmdNext_Click()
Dim Value As Double
Dim Average As Double
Value = CDbl(txtValue.Text)
Number = CInt(txtCount.Text)
Sum = CDbl(txtSum.Text)
Average = CDbl(txtAverage.Text)
Number = Number + 1
Sum = Sum + Value
Average = Value / Number
End Sub
Private Sub cmdExit_Click()
Unload Form1
End
End Sub
Thank you in advance for the help!
Kevin