I have made an application to add monthly usages of coffee to a listbox using an array. I have a button which opens up an InputBox to enter the monthly usages. I then click a button to display the usages in a listbox. Howerver, I only want users to be able to add numbers to the listbox so when a user clicks enters a non-numeric value or enters nothing at all and clicks OK, a MsgBox appears. I have tried many different ways but none seem to work. Please help!
Public Class frmCostaLot
Dim MonthlyUsages(11) As Single
Private Sub lstUsageAmount_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstUsageAmount.SelectedIndexChanged
End Sub
Private Sub btnEnterUsages_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEnterUsages.Click
Dim usages As Integer
For usages = 0 To 11
MonthlyUsages(usages) += InputBox("Please enter a monthly usage value")
Next
End Sub
Private Sub btnShowUsages_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnShowUsages.Click
Dim usages As Integer
For usages = 0 To 11
lstUsageAmount.Items.Add(MonthlyUsages(usages))
Next
End Sub