- Home
·
- Math/Dates
·
- Calculate and show the Average result (in percent) and add to a ListBox
Calculate and show the Average result (in percent) and add to a ListBox
Calculate and show the Average result (in percent) and add to a ListBox
API Declarations
Dim Attempts As Integer
Dim Hits As Integer
Controls :
2 TextBoxes Name : Text1 & Text2
Commandbutton Name : Command1
ListBox Name : List1
Rate Calculate and show the Average result (in percent) and add to a ListBox
(2(2 Vote))
'European date : 11/8/2005
'Please see my other Snippets on page 607,609 and 610
Private Sub Command1_Click()
Attempts = Val(Text1): Hits = Val(Text2)
'Validate Hits > Attempts
If Hits > Attempts Then
MsgBox "Hits must be lower than Attempts"
Command1.Caption = " No result "
Else
'Calculate percent
Average = Format(Hits / Attempts, "percent")
'Show result (average percent) on the Commandbutton
Command1.Caption = "Average : " & Average
'Add result to Listbox
List1.AddItem Attempts & " - " & Hits & " = " & Average
End If
End Sub
Calculate and show the Average result (in percent) and add to a ListBox Comments
No comments yet — be the first to post one!
Post a Comment