Desktop Minicalendar with vb.net


A simple Desktop Minicalendar application with vb.net for beginners.Simply display splash type calendar in windows desktop below right corner (look like vista, win7 widget).Unable to close the application. And run this application with windows startup.

Desktop Minicalendar with vb.net


Intoduction


This article for basic learners.In this article i will show, how to create a mini calendar desktop application and run with windows startup.

Step by step programming


Step1:


Create a windows application in visual studio and change form width & height to 150 (looklike small widget),set showintaskbar to false, change fromeborderstyle to none.Now add TableLayoutPanel control to windows form. Add 4 rows to TableLayoutPanlel. Add 4 Label controls to these 4 rows. And change font type, color, size good looking UI.

Step2:


Now change the 4 label names and change text property to "".
1) label1 -> Time_Label
2) label2 -> Month_Label
3) label3 -> Date_Label
4) label4 -> Week_Label

Step3:


Here we can set form position at desktop below right corner.
For this form_load() event write the code.

Dim x As Integer
Dim y As Integer
x = Screen.PrimaryScreen.WorkingArea.Width - Me.Width
y = Screen.PrimaryScreen.WorkingArea.Height - Me.Height
Me.Location = New Point(x, y)

Step:4


Here we can add our application to windows startup.
For this we add a registry key to windows registry run folder.
For this first import Microsoft.Win32 namespace, and add below code to form_load() event

Imports Microsoft.Win32
Dim regStartUp As RegistryKey regStartUp = Registry.CurrentUser.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True)
regStartUp.CreateSubKey("MiniCalendar")
regStartUp.SetValue("MiniCalendar", Application.ExecutablePath.ToString())
regStartUp.Close()

Step:5


Here we can write code for display time, month, day, week in 4 labels.
For continuous update of time, day, month, week we add a timer control to windows form. Set timer control enable property to true in form_load() event write the below code in a sub procedure and call it to required places(timer_tick event).

Public Sub load_calendar()
Dim month As String = Date.Now.Month.ToString()

If month = "1" Then
month = "January"
End If
If month = "2" Then
month = "February"
End If
If month = "3" Then
month = "March"
End If
If month = "4" Then
month = "April"
End If
If month = "5" Then
month = "May"
End If
If month = "6" Then
month = "June"
End If
If month = "7" Then
month = "July"
End If
If month = "8" Then
month = "August"
End If
If month = "9" Then
month = "September"
End If
If month = "10" Then
month = "October"
End If
If month = "11" Then
month = "November"
End If
If month = "12" Then
month = "December"
End If

Dim t As DateTime = DateTime.Now
Time_Label.Text = t.ToLongTimeString()
Month_Label.Text = month
Date_Label.Text = Date.Now.Day.ToString()
Week_Label.Text = Date.Now.DayOfWeek.ToString()
End Sub


Step:6


Now we can call above procedure in timer-tick event and form_load() events.
Add a global variable for display splash day, month.

'Add global variable
Dim d As Integer = 1
'write below code in form load event
Time_Label.Text = "Loading......"
load_calendar()
Timer1.Enabled = True
'write below code in timer tick event
load_calendar()
If d = 1 Then
Month_Label.Visible = False
Week_Label.Visible = True
d = 0
Else
Week_Label.Visible = False
Month_Label.Visible = True
d = 1
End If

Step:7


Here we write code for unable to close form.
For this write below code in form_closing event.

e.cancel=true

Step8:


Total Program Coding for this application

Imports System.Threading
Imports Microsoft.Win32
Public Class MiniCalendar
Dim d As Integer = 1

Public Sub MiniCalendar()



End Sub
Private Sub MiniCalendar_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim regStartUp As RegistryKey
regStartUp = Registry.CurrentUser.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True)
regStartUp.CreateSubKey("MiniCalendar")
regStartUp.SetValue("MiniCalendar", Application.ExecutablePath.ToString())
regStartUp.Close()
Dim x As Integer
Dim y As Integer
x = Screen.PrimaryScreen.WorkingArea.Width - Me.Width
y = Screen.PrimaryScreen.WorkingArea.Height - Me.Height
Me.Location = New Point(x, y)

Time_Label.Text = "Loading......"

load_calendar()
Timer1.Enabled = True

End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick


load_calendar()

If d = 1 Then
Month_Label.Visible = False
Week_Label.Visible = True
d = 0
Else
Week_Label.Visible = False
Month_Label.Visible = True
d = 1
End If


End Sub

Private Sub MiniCalendar_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs)
e.Cancel = True
End Sub
Public Sub load_calendar()
Dim month As String = Date.Now.Month.ToString()

If month = "1" Then
month = "January"
End If
If month = "2" Then
month = "February"
End If
If month = "3" Then
month = "March"
End If
If month = "4" Then
month = "April"
End If
If month = "5" Then
month = "May"
End If
If month = "6" Then
month = "June"
End If
If month = "7" Then
month = "July"
End If
If month = "8" Then
month = "August"
End If
If month = "9" Then
month = "September"
End If
If month = "10" Then
month = "October"
End If
If month = "11" Then
month = "November"
End If
If month = "12" Then
month = "December"
End If

Dim t As DateTime = DateTime.Now
Time_Label.Text = t.ToLongTimeString()
Month_Label.Text = month
Date_Label.Text = Date.Now.Day.ToString()
Week_Label.Text = Date.Now.DayOfWeek.ToString()
End Sub


End Class


Attachments

  • Minicalendar Desktop Application (43873-223939-Minicalendar-Desktop-Application.rar)
  • Comments

    No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: