Member Avatar

Hi, I have made a code where I write a recipe to a file and then I can read from the file and it is output in a listbox. I need to allow the user to change the amount of people served and then the quantities change to suit the serving number. The serving number is input and the rest of the code works apart from the changing the quantities bit.

The code that I am using is below. I have no idea if i'm doing it right though.

Private Sub btnOKServed_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOKServed.Click
                Dim FileReader As New IO.StreamReader("E:\" & lstRecipeChoose.Text & ".txt")
                Dim charcounter As Double
                Do While FileReader.Peek <> -1
                    StrEntry = FileReader.ReadLine().ToString
                    If StrEntry.StartsWith(Ingredients & "Quantity and units: ") Then
                        Quantity = StrEntry.Substring(charcounter + 20, 3)
                        NewIngredientsAndUnits = StrEntry.Substring(charcounter + 24)
                        Quantity = lstExistingRecipe.Text / PeopleServed * NewPeopleServed
                        NewRecipe = Ingredients & "Quantity and units: " & Quantity & NewIngredientsAndUnits
                    End If

            End Sub

Thanks in advance!


Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.