My next problem is getting the bakery items to insert after the "Turn on, Heat" text in the list box and before the other 3 texts. ATM they are just going after everything.
I hope I understand this correctly. If you wish to insert them before other texts, you can't use lbxOven1.Items.Add() because that will simply put the new string at the end. You should make use of the lbxOven1.Items array to figure out where to put the next item. (but see my last idea, below).
I also need to work out how to get them to add the time that's in the brackets to the time shown next to them as shown in the image in Oven 2.
The start time text box is a string so will also need a way to avoid getting bad times such as 9:73 instead of 10:13.
One idea that would solve all of these problems is to keep the operations and times in either two arrays or an array of struct.
Private Structure OvenStruc
Public OvenOp As String
Public Optime As DateTime
End Structure
Private OvenOps() As OvenStruc
' This assumes that Op.Optime is properly set before calling this routine
' it adds a record to the OvenOps array.
Private Sub AddOperation(ByVal Op As OvenStruc)
Dim index As Integer
Dim found As Boolean = False
For i As Integer = 0 To OvenOps.GetUpperBound(0)
If Op.Optime > OvenOps(i).Optime Then
index = i
found = True
Exit For
End If
Next
ReDim Preserve OvenOps(OvenOps.GetUpperBound(0) + 1) ' enlarge the OvenOps array
If found Then ' add at index
For i As Integer = index To OvenOps.GetUpperBound(0) - 1
OvenOps(i + 1) = OvenOps(i)
Next
OvenOps(index) = Op ' insert the operation
Else ' add at the end
OvenOps(OvenOps.GetUpperBound(0)) = Op
End If
End Sub
' This deletes an operation from the OvenOps array.
Private Sub DeleteOperation(ByVal index As Integer)
If OvenOps.Length >= 1 Then
Dim Counter As Integer = OvenOps.GetUpperBound(0)
For i As Integer = index To Counter - 1
OvenOps(i) = OvenOps(i + 1)
Next
ReDim Preserve OvenOps(Counter - 1)
End If
End Sub
Private Sub Fill_Listbox()
Dim TimeStr As String
lbxOven1.Items.Clear() ' completely empty the listbox.
For i As Integer = 0 To OvenOps.GetUpperBound(0)
TimeStr = Format(OvenOps(i).Optime, "hh:mm tt ")
lbxOven1.Items.Add(TimeStr & OvenOps(i).OvenOp)
Next
lbxOven1.Refresh()
End Sub
When you wish to add an item to the array, you enter the time and the operation into the OvenOps array; then call AddOperation. If you wish to delete something, call DeleteOperation. Of course you'll still have to adjust some of the times somewhere, but it should be simpler since the times will be in the DateTime format. That format is easier to handle -- to add or subtract times from.
Instead of parsing strings from the listbox, simply fill the listbox each time there's a change. Fill_Listbox shows how this is done.