How to Create a Reminder Tool in Visual Basic

Submitted by: 
Language: 
Visitors have accessed this post 12613 times.

Introduction:
Welcome to a tutorial on how to create a reminder tool in Visual Basic.

Steps of Creation:
Step 1:

First we want to create a form with;
Button1 - to add a new reminder
Label2 - to store the current time
Textbox1 - to store the text of a new reminder
Textbox2 - to store the time of a new reminder

Step 2:
Next we want to create some custom functions, the titles of each explain exactly what they do...

  1. Private Function updateShowingTimer()
  2. Dim time As Date =TimeValue(Now)
  3. Label2.Text = time
  4. End Function
  5. Private Function checkExistings()
  6. If (ListBox1.Items.Count()) Then
  7. For Each l As String In ListBox1.Items
  8. Dim t As String() = l.Split(" Starts At ")
  9. Dim time As String = l.Substring(0, 9)
  10. Dim msg As String = l.Substring(19, l.Count() - 19)
  11. If (TimeValue(Now) = time) Then
  12. MsgBox(msg)
  13. End If
  14. Next
  15. End If
  16. End Function
  17. Private Function constaUpdate()
  18. Do While True
  19. updateShowingTimer()
  20. checkExistings()
  21. Threading.Thread.Sleep(1000)
  22. Loop
  23. End Function
  24. Private Function isRightTimeForamat(ByVal s As String)
  25. If (s.Contains(":")) Then
  26. Dim total As Integer = 0
  27. For Each c As Char In s
  28. If (c = ":") Then total += 1
  29. Next
  30. If (total = 2) Then
  31. Dim all As String() = s.Split(":")
  32. Dim isRight As Boolean = True
  33. For Each a As String In all
  34. If (Not a.Count() = 2) Then isRight = False
  35. Next
  36. If (isRight) Then
  37. Return True
  38. Else : Return False
  39. End If
  40. End If
  41. End If
  42. Return False
  43. End Function

Step 3:
On form load we want to disable CheckForIllegalCrossThreadCalls to avoid errors when trying to set the current time from a new thread, which we also create on form load, which deals with the secondly updating of the current time label.

  1. Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  2. CheckForIllegalCrossThreadCalls = False
  3. Dim trd As Threading.Thread = New Threading.Thread(AddressOf constaUpdate)
  4. trd.IsBackground = True
  5. trd.Start()
  6. updateShowingTimer()
  7. End Sub

Step 4:
Finally, we want to make the add new reminder button function. This is where our custom made functions come in to play...

  1. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  2. If (isRightTimeForamat(TextBox2.Text)) Then
  3. If (Not TextBox1.Text = Nothing) Then
  4. ListBox1.Items.Add(TextBox2.Text & " Starts At " & TextBox1.Text)
  5. End If
  6. End If
  7. End Sub

Project Complete!
Below is the full source code and download to the project files.

  1. Public Class Form1
  2. Private Function updateShowingTimer()
  3. Dim time As Date =TimeValue(Now)
  4. Label2.Text = time
  5. End Function
  6. Private Function checkExistings()
  7. If (ListBox1.Items.Count()) Then
  8. For Each l As String In ListBox1.Items
  9. Dim t As String() = l.Split(" Starts At ")
  10. Dim time As String = l.Substring(0, 9)
  11. Dim msg As String = l.Substring(19, l.Count() - 19)
  12. If (TimeValue(Now) = time) Then
  13. MsgBox(msg)
  14. End If
  15. Next
  16. End If
  17. End Function
  18. Private Function constaUpdate()
  19. Do While True
  20. updateShowingTimer()
  21. checkExistings()
  22. Threading.Thread.Sleep(1000)
  23. Loop
  24. End Function
  25. Private Function isRightTimeForamat(ByVal s As String)
  26. If (s.Contains(":")) Then
  27. Dim total As Integer = 0
  28. For Each c As Char In s
  29. If (c = ":") Then total += 1
  30. Next
  31. If (total = 2) Then
  32. Dim all As String() = s.Split(":")
  33. Dim isRight As Boolean = True
  34. For Each a As String In all
  35. If (Not a.Count() = 2) Then isRight = False
  36. Next
  37. If (isRight) Then
  38. Return True
  39. Else : Return False
  40. End If
  41. End If
  42. End If
  43. Return False
  44. End Function
  45. Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  46. CheckForIllegalCrossThreadCalls = False
  47. Dim trd As Threading.Thread = New Threading.Thread(AddressOf constaUpdate)
  48. trd.IsBackground = True
  49. trd.Start()
  50. updateShowingTimer()
  51. End Sub
  52.  
  53. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  54. If (isRightTimeForamat(TextBox2.Text)) Then
  55. If (Not TextBox1.Text = Nothing) Then
  56. ListBox1.Items.Add(TextBox2.Text & " Starts At " & TextBox1.Text)
  57. End If
  58. End If
  59. End Sub
  60. 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.

Comments

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

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • You may insert videos with [video:URL]
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <th> <img> <h1> <h2> <h3> <iframe> [video]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.