Hello, I am new i vb .I need to . Each asterisk represents $100 in sales by using for next loop.
also i have a problem i do not want it to go next store until the data in the first store is correct, and so on
the problem say
application that prompts the user to enter todays’s sales for five stores. Create a loop to prompt for an amount for the first store using an inputbox and do not exit until you have good data. The inputs cannot be negative or greater than 5000, but may contain decimal values.
The program should then display a simple bar graph corresponding to the amount of sales using a row of asterisks (*) in a listbox. Each asterisk represents $100 in sales. Display the total of all the stores by looping this process for each store.
.
my code .
Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
Dim intCount As Integer = 1
Dim strInputs As String 'To hold user inputs
Dim DecStoreSales As Decimal 'to Hold store's sales
Dim intAsteriskValue As Integer = 100 '*.
Dim intTotalAsterisk As Integer ' The number of asterisks to display
Dim strAsterisks As String ' Asterisks
Dim strOut As String = String.Empty
Try
For intCount = 1 To 5
strInputs = InputBox("Enter Todays’s Sales for store " & intCount, "Store Sales")
If Not Decimal.TryParse(strInputs, DecStoreSales) Then
MessageBox.Show("store Sales Must be Numeric", "Store Sales Error")
ElseIf DecStoreSales < 0 Or DecStoreSales > 5000 Then
MessageBox.Show("Store sales can not be less than 0 or Greater than 5000", "store sales Error")
Else
intTotalAsterisk = CInt(Math.Round(DecStoreSales / intAsteriskValue))
For intTotalAsterisk = 1 To intTotalAsterisk
strAsterisks &= "*"
Next
End If
strOut = ("store " & intCount.ToString() & " " & DecStoreSales.ToString("c") & ":" & strAsterisks.ToString)
lstSales.Items.Add(strOut)
Next intCount
Catch ex As Exception
End Try
End Sub