kay so we have an activity, the activity was to make a simple cashier system using filestream.
So the layout will be there are 3 radio buttons ( foods,drinks,desserts)
so for example i chose foods the comboBox will automatically update it's value like a list
of foods. I already had this function, my problem is the i cannot get the value of it.
this is the structure of the textfile
Hamburger:10
Fries:20.4
Here's my code:
Public Class Form1
Private Sub foodRadioBtn_CheckedChanged(sender As Object, e As EventArgs) Handles foodRadioBtn.CheckedChanged
CalculateStuff("food.txt")
End Sub
Private Sub DrinksRadioBtn_CheckedChanged(sender As Object, e As EventArgs) Handles DrinksRadioBtn.CheckedChanged
CalculateStuff("drinks.txt")
End Sub
Dim prices(100) As String
Private Sub DessertsRadioBtn_CheckedChanged(sender As Object, e As EventArgs) Handles DessertsRadioBtn.CheckedChanged
CalculateStuff("desserts.txt")
End Sub
Sub CalculateStuff(filePath As String)
ComboBox1.Text = ""
ComboBox1.Items.Clear()
Dim lines() As String = IO.File.ReadAllLines(filePath)
Dim count As Integer = 0
Do
Dim splitter() As String = lines(count).Split(":")
ComboBox1.Items.Add(splitter(0))
' prices(count) = CDbl(splitter(1))
count += 1
Loop Until count = lines.Length
End Sub
Dim amount As Double = 0
Private Sub insertBtn_Click(sender As Object, e As EventArgs) Handles insertBtn.Click
amountLbl.ForeColor = Color.Green
amount += CDbl(insertCashTxt.Text)
amountLbl.Text = amount
End Sub
Private Sub payBtn_Click(sender As Object, e As EventArgs) Handles payBtn.Click
MessageBox.Show("Payment Accepted")
changeTxt.Text = amount - CDbl(totalTxt.Text)
End Sub
Private Sub quantityTxt_TextChanged(sender As Object, e As EventArgs) Handles quantityTxt.TextChanged
nstextbox2.text = prices(ComboBox1.SelectedIndex) * CInt(quantityTxt.Text)
End Sub
End Class
it is giving me an error "Index was outside the bounds of the array."
Thanks!