Hi; Just thought i'd share my Birthday reminder program in VBE 2005.
It is a database with just two fields, birthdate and name. You can put anything in the name field for a reminder. Program works good, but what i'd to do is have it auto start on boot-up. In minimized mode, to search if any birthdays are today, if so, then maximize to notify the user.
Code:
Imports System
Imports System.IO
Public Class Form1
Dim fname, line, pad As String
Dim files(500) As String
Dim rec, recs, i As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
pad = " "
fname = "birthdays.txt"
recs = 0
If My.Computer.FileSystem.FileExists(fname) Then
Try
Using sr As StreamReader = New StreamReader(fname)
'Dim line As String
' Read and display the lines from the file until the end of the file is reached.
Do
line = sr.ReadLine()
If line = "" Then Exit Do
files(recs) = line
recs = recs + 1
Loop Until line Is Nothing
sr.Close()
End Using
Catch er As Exception
' Let the user know what went wrong.
MsgBox("The file could not be read:" & " " & er.Message)
End Try
Msg.Text = (recs & " Records")
Call display()
For i = 0 To recs - 1
If Mid(files(i), 1, 10) > DateString Then Exit For
Next
rec = i
Call display()
End If
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Today.Text = DateString & " " & TimeString
End Sub
Private Sub TSBload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TSBload.Click
fname = "birthdays.txt"
recs = 0
If My.Computer.FileSystem.FileExists(fname) Then
Try
Using sr As StreamReader = New StreamReader(fname)
' Read and display the lines from the file until the end of the file is reached.
Do
line = sr.ReadLine()
If line = "" Then Exit Do
files(recs) = line
recs = recs + 1
Loop Until line Is Nothing
sr.Close()
End Using
Catch er As Exception
' Let the user know what went wrong.
MsgBox("The file could not be read:" & " " & er.Message)
End Try
Msg.Text = (recs & " Records")
Call display()
End If
End Sub
Private Sub TSBsave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TSBsave.Click
fname = "Birthdays.txt"
Try
' Create an instance of StreamReader to read from a file.
Using sw As StreamWriter = New StreamWriter(fname)
' Add some text to the file.
For i = 0 To recs - 1
sw.WriteLine(files(i))
Next
sw.Close()
End Using
Catch er As Exception
' Let the user know what went wrong.
MsgBox("Error " & er.Message)
End Try
Msg.Text = recs & " Records Saved to: " & fname
End Sub
Private Sub TSBadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TSBadd.Click
line = TBdate.Text & pad
line = Mid(line, 1, 10)
line = line & " " & TBname.Text
files(recs) = line
recs = recs + 1
Call display()
End Sub
Sub display()
RichTextBox1.Clear()
Array.Sort(files, 0, recs)
For i = 0 To recs - 1
RichTextBox1.AppendText(Mid(files(i), 1, 10) & Mid(files(i), 11) & vbCrLf)
Next
'rec = 0
TBdate.Text = Mid(files(rec), 1, 10)
TBname.Text = Mid(files(rec), 13)
TBage.Text = " "
If Mid(files(rec), 7, 4) > "1900" Then
i = Val(Mid(files(rec), 7, 4))
i = Val(Mid(DateString, 7, 4)) - i
TBage.Text = Str(i)
End If
End Sub
Private Sub TSBupdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TSBupdate.Click
line = TBdate.Text & pad
line = Mid(line, 1, 10)
line = line & " " & TBname.Text
files(rec) = line
Call display()
End Sub
Private Sub TSBfwd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TSBfwd.Click
rec = rec + 1
If rec > recs - 1 Then rec = 0
Call display()
Msg.Text = ("Record " & rec)
End Sub
Private Sub TSBback_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TSBback.Click
rec = rec - 1
If rec < 0 Then rec = recs - 1
Call display()
Msg.Text = ("Record " & rec)
End Sub
Private Sub TSBdelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TSBdelete.Click
files(rec) = Chr(255)
Array.Sort(files, 0, recs)
recs = recs - 1
Call display()
End Sub
End Class
could you tell me what boxes and stuff are you using (eg list box, timer) I am making my own birthday reminder but I don't understand how to code few things!