How to Create a Notify Icon in VB.net with Source Code

How to Create a Notify Icon in VB.net with Source Code

This tutorial is all about How to Create a Notify Icon in VB.Net.

This time, I’m going to make a simple NotifyIcon in VB.NET. This NotifyIcon includes the current date and the kind of operating system (OS) that you are using and It will appear into the system tray of your computer.

What is Visual Basic’s purpose?

VB.Net Login Code With MySQL Databa... x
VB.Net Login Code With MySQL Database Tutorial of [2019]Best Practices with [Full Source Code]

The third-generation programming language was created to aid developers in the creation of Windows applications. It has a programming environment that allows programmers to write code in.exe or executable files. They can also utilize it to create in-house front-end solutions for interacting with huge databases. Because the language allows for continuing changes, you can keep coding and revising your work as needed.

However, there are some limits to the Microsoft Visual Basic download. If you want to make applications that take a long time to process, this software isn’t for you. That implies you won’t be able to use VB to create games or large apps because the system’s graphic interface requires a lot of memory and space. Furthermore, the language is limited to Microsoft and does not support other operating systems.

What are the most important characteristics of Visual Basic?

Microsoft Visual Basic for Applications Download, unlike other programming languages, allows for speedier app creation. It has string processing capabilities and is compatible with C++, MFC, and F#. Multi-targeting and the Windows Presentation Framework are also supported by the system, allowing developers to create a variety of Windows apps, desktop tools, metro-style programs, and hardware drivers.

So, let’s begin:
Open the Visual Basic and create a new Windows Form Application. Drag a “ContextMenuStrip”, ”NotifyIcon”, ”Button” and it will look like this.
notifyiconform

After that, click the ContextMenuStrip and add the following items into it.
notifyiconform1

After adding the items, double click the “Current Date and Time” to fire the click event handler of it. Set the current date and time in the pop-up message.

[vbnet]
Private Sub CurrentDateAndTimeToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CurrentDateAndTimeToolStripMenuItem.Click
‘GET THE CURRENT DATE
MsgBox(“Today is ” & My.Computer.Clock.LocalTime.ToLongDateString & “.”)
End Sub
[/vbnet]

After that, go back to the Form Design and double click the “Operating System (OS) Version” to fire the click event handler of it. Set the current OS version in the pop-up message.

[vbnet]
Private Sub OperatingSystemOSToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OperatingSystemOSToolStripMenuItem.Click
‘GET THE CURRENT OPERATING SYSTEM INFORMATION
MsgBox(My.Computer.Info.OSFullName & vbCrLf & “Version ” & My.Computer.Info.OSVersion)
End Sub
[/vbnet]

Go back to the Form Design again and double click the “exit” to fire the click event handler of it. Put this code for closing the application.

[vbnet]
Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
‘HIDE THE ICON BEFORE CLOSING THE FORM .
NotifyIcon1.Visible = False
ME.CLOSE
End Sub
[/vbnet]

Go back to the Form Design again, double click the Button and put the code in the click event handler of the Button. This method is for hiding the Form and showing the icon in the system tray.

[vbnet]
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
‘SET THE NOTIFYICON TO MAKE IT APPEAR INTO THE SYSTEM TRAY
NotifyIcon1.Visible = True
NotifyIcon1.Text = “System Information”
‘HIDDING THE FORM
Me.Hide()
End Sub
[/vbnet]

Now, double click the NotifyIcon and put this code into the mousedoubleclick event handler of it.

[vbnet]
Private Sub NotifyIcon1_MouseDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles NotifyIcon1.MouseDoubleClick
‘WHEN YOU DOUBLE CLICK THE ICON IT WILL DISAPPEAR IN THE SYSTEM TRAY AND THE FORM WILL BE APPEAR.
NotifyIcon1.Visible = False
Me.Show()
End Sub
[/vbnet]

Finally, hide the notifyIcon on the first load of the Form.

[vbnet]
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
‘DISAPPEARING THE ICON IN THE SYSTEM TRAY ON THE FIRST LOAD.
NotifyIcon1.Visible = False
Me.Hide()
End Sub
[/vbnet]

You can download the complete source code.

Readers might read also:

1 thought on “How to Create a Notify Icon in VB.net with Source Code”

  1. I must say it was hard to find your page in google.
    You write great articles but you should rank your blog higher
    in search engines. If you don’t know how to do it
    search on youtube: how to rank a website Marcel’s way

    Reply

Leave a Comment