0
我是vb的初學者,我將在商店銷售中每100顯示*;但是,在循環中重新打印之前輸入的值。謝謝你的幫助。爲什麼我的循環無法正常工作visual basic
我要添加到列表如下:
- 店1:**
- 店2 *****
每* = 100
Public Class Exercise6
Private Sub btnDisplay_Click(sender As Object, e As EventArgs) Handles btnDisplay.Click
Const intNumberOfDays As Integer = 5 'days
Dim intSales As Decimal = 0 'to hold daily sales
Dim strUserInput As String 'to hold user input
Dim strAsterisks As String = "" 'Asterisks
Const intAsterisk As Integer = 100
Dim intAsteriskTotal As Integer
Dim strDataOut As String = String.Empty 'holds the list output
Dim intCounter As Integer = 1
'gets sales for 5 stores
Do While intCounter <= intNumberOfDays
strUserInput = InputBox("Enter the sales for store" &
intCounter.ToString(), "Store Sales is Needed")
If strUserInput <> String.Empty And IsNumeric(strUserInput) Then
intSales = CInt(strUserInput)
'calculate the number of asterisk that must be display
intAsteriskTotal = CInt(intSales/intAsterisk)
strAsterisks = New String(CChar("*"), intAsteriskTotal)
'add the store to the output string
strDataOut &= "Store " & intCounter.ToString() & ": " & strAsterisks
'add the output to the list box
lstChart.Items.Add(strDataOut)
intCounter += 1
Else
MessageBox.Show("Please enter a proper value for store sales.")
End If
Loop
End Sub
End Class