The problem I'm having is a bit more complicated than the title of the thread, but I wasn't sure how else to word it. Anyway, here goes...
Here's what I'm attempting to do:
Add a string to a listbox (object)
check the current time
if the listbox item date string is before now() then it will remove the items from the listbox
Check the first X items in the listbox and pull a ticket number from the string (object) in the listbox
Most of it I've got down. the trouble I'm having is trying to pull the ticket number from the listbox object for the first X items in the listbox.
The listbox item looks like this:
Ticket 1: 3:30 PM
Ticket 2: 3:30 PM
Ticket 3: 3:30 PM
Ticket 4: 3:30 PM
Ticket 5: 3:30 PM
Ticket 6: 3:35 PM
Ticket 7: 3:35 PM
Ticket 8: 3:35 PM
Ticket 9: 3:35 PM
Ticket 10: 3:35 PM
Ticket 11: 3:40 PM
Etc.
Once 3:30 PM comes around Tickets 1 through 5 would be removed from the listbox. What I want to do after they're removed is create a string with the ticket numbers; "1-5". And once 3:35 PM came around the string would update to 6-10 and tickets 6 through 10 would be removed from the listbox. I've got the code down for removing the items from the listbox based on a timer control.
and TicketClass
So in the timer control I need the PREVIOUS X number of tickets (a set variable based on an option form called guestsPer) to show up as "first ticket" - "last ticket in series".
I've been staring at this for two days trying to work it out and I can't for the life of me get this part done. Once this is done and I get some validation taken care of the program will be done...
Thank you so much in advance!!
Here's what I'm attempting to do:
Add a string to a listbox (object)
check the current time
if the listbox item date string is before now() then it will remove the items from the listbox
Check the first X items in the listbox and pull a ticket number from the string (object) in the listbox
Most of it I've got down. the trouble I'm having is trying to pull the ticket number from the listbox object for the first X items in the listbox.
Code:
Private Sub btnIssue_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnIssue.Click
txtNextTime.Text = Format(TimeClass.getNextTime, "h:mm tt")
lstMain.Items.Add("Ticket " & TicketClass.ticketNumber & ": " & Format(TimeClass.getNextTime, "h:mm tt"))
lstMain. = TicketClass.ticketNumber
TicketClass.ticketNumber = TicketClass.ticketNumber + 1
TimeClass.currentGuests = TimeClass.currentGuests + 1
txtOutstanding.Text = lstMain.Items.Count
'testing stuff
' Dim testtime As Date
'testtime = DateAdd(DateInterval.Minute, TimeClass.minutesPer, (TimeClass.getNextTime.Subtract(TimeSpan.FromMinutes(TimeClass.minutesPer * TimeClass.timesCount))))
TimeClass.originalTime = DateAdd(DateInterval.Minute, TimeClass.minutesPer, (TimeClass.getNextTime.Subtract(TimeSpan.FromMinutes(TimeClass.minutesPer * TimeClass.timesCount))))
If TimeClass.guestCount = TimeClass.guestsPer Then
' txtTest.Text = Format((TimeClass.originalTime.Subtract(TimeSpan.FromMinutes(TimeClass.minutesPer * (TimeClass.timesCount)))), "h:mm tt")
TimeClass.formattedTime = Format(TimeClass.originalTime.Add(TimeSpan.FromMinutes(TimeClass.minutesPer)), "h:mm tt")
Else
TimeClass.formattedTime = Format(TimeClass.originalTime, "h:mm tt")
End If
txtTest3.Text = ""Ticket 1: 3:30 PM
Ticket 2: 3:30 PM
Ticket 3: 3:30 PM
Ticket 4: 3:30 PM
Ticket 5: 3:30 PM
Ticket 6: 3:35 PM
Ticket 7: 3:35 PM
Ticket 8: 3:35 PM
Ticket 9: 3:35 PM
Ticket 10: 3:35 PM
Ticket 11: 3:40 PM
Etc.
Once 3:30 PM comes around Tickets 1 through 5 would be removed from the listbox. What I want to do after they're removed is create a string with the ticket numbers; "1-5". And once 3:35 PM came around the string would update to 6-10 and tickets 6 through 10 would be removed from the listbox. I've got the code down for removing the items from the listbox based on a timer control.
Code:
Private Sub tmrOne_tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrCount.Tick
Me.Text = FormatDateTime(Now, DateFormat.LongTime) & " " & TimeClass.checkStatus
Dim checkDate As Date = Format(Now, "h:mm tt")
If TimeClass.oldTime <= checkDate Then
TicketClass.removeListItems(TimeClass.oldTime)
txtOutstanding.Text = lstMain.Items.Count
txtNextTime.Text = Format(TimeClass.getNextTime, "h:mm tt")
End If
txtTest2.Text = TimeClass.getNextTime
End SubCode:
Public Class TicketClass
Public Shared Property firstTicket As Integer
Public Shared Property ticketStatus As String
Public Shared Property ticketNumber As Integer
Public Shared Property ticketValue As New Collection
Public Shared Function removeListItems(ByVal str As String) As Boolean
Dim i As Integer
For i = 0 To frmMain.lstMain.Items.Count - 1
If InStr(frmMain.lstMain.Items(i), str) > 0 Then
frmMain.lstMain.Items.RemoveAt(i)
Exit For
End If
Next
Return True
End Function
End ClassI've been staring at this for two days trying to work it out and I can't for the life of me get this part done. Once this is done and I get some validation taken care of the program will be done...
Thank you so much in advance!!