There's a problem when
There's a problem when switching textbox1 and 2 so that it may appear here:
"ListBox1.Items.Add(TextBox2.Text & " Starts At " & TextBox1.Text)"
Why is that? Program stops working but somehow it works like this
Private Function updateShowingTimer() Dim time As Date =TimeValue(Now) Label2.Text = time End Function Private Function checkExistings() If (ListBox1.Items.Count()) Then For Each l As String In ListBox1.Items Dim t As String() = l.Split(" Starts At ") Dim time As String = l.Substring(0, 9) Dim msg As String = l.Substring(19, l.Count() - 19) If (TimeValue(Now) = time) Then MsgBox(msg) End If Next End If End Function Private Function constaUpdate() Do While True updateShowingTimer() checkExistings() Threading.Thread.Sleep(1000) Loop End Function Private Function isRightTimeForamat(ByVal s As String) If (s.Contains(":")) Then Dim total As Integer = 0 For Each c As Char In s If (c = ":") Then total += 1 Next If (total = 2) Then Dim all As String() = s.Split(":") Dim isRight As Boolean = True For Each a As String In all If (Not a.Count() = 2) Then isRight = False Next If (isRight) Then Return True Else : Return False End If End If End If Return False End Function
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load CheckForIllegalCrossThreadCalls = False Dim trd As Threading.Thread = New Threading.Thread(AddressOf constaUpdate) trd.IsBackground = True trd.Start() updateShowingTimer() End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click If (isRightTimeForamat(TextBox2.Text)) Then If (Not TextBox1.Text = Nothing) Then ListBox1.Items.Add(TextBox2.Text & " Starts At " & TextBox1.Text) End If End If End Sub
Public Class Form1 Private Function updateShowingTimer() Dim time As Date =TimeValue(Now) Label2.Text = time End Function Private Function checkExistings() If (ListBox1.Items.Count()) Then For Each l As String In ListBox1.Items Dim t As String() = l.Split(" Starts At ") Dim time As String = l.Substring(0, 9) Dim msg As String = l.Substring(19, l.Count() - 19) If (TimeValue(Now) = time) Then MsgBox(msg) End If Next End If End Function Private Function constaUpdate() Do While True updateShowingTimer() checkExistings() Threading.Thread.Sleep(1000) Loop End Function Private Function isRightTimeForamat(ByVal s As String) If (s.Contains(":")) Then Dim total As Integer = 0 For Each c As Char In s If (c = ":") Then total += 1 Next If (total = 2) Then Dim all As String() = s.Split(":") Dim isRight As Boolean = True For Each a As String In all If (Not a.Count() = 2) Then isRight = False Next If (isRight) Then Return True Else : Return False End If End If End If Return False End Function Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load CheckForIllegalCrossThreadCalls = False Dim trd As Threading.Thread = New Threading.Thread(AddressOf constaUpdate) trd.IsBackground = True trd.Start() updateShowingTimer() End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click If (isRightTimeForamat(TextBox2.Text)) Then If (Not TextBox1.Text = Nothing) Then ListBox1.Items.Add(TextBox2.Text & " Starts At " & TextBox1.Text) End If End If End Sub End Class
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.
Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.
FOR YOUR OWN SAFETY, PLEASE:
1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.