Get the Zodiac Sign Based on Date of Birth - Visual Basic .NET

Tags: VB.NET, VB 2008, VB 2010, VB 2012, VB 2013

This is a tutorial on how to make a program that returns the zodiac sign according to date of birth in Visual Basic .NET

Add the following controls to your form:
DateTimePicker
3 Labels
Button
TextBox
PictureBox

Change the TextBox MultiLine property to True (Click on the small arrow on top right corner of the textbox and check the MultiLine box).

Change the PictureBox Size Mode to Zoom. Click on the small arrow on top right corner, then change the size to Zoom

zodiac sign with pictures in visual basic .net

This is how my form looks like after adding and arranging the controls.

Add the Zodiac Sign images to the picturebox. You can download the pictures here. Extract the images and put them in folder. Click on right top arrow --> click on Choose Image --> Check Project Resource File --> Click on Import
Browser to the folder where your zodiac signs located, select them all, and click open. All images will be imported to your resource folder in your project.

get the zodiac sign in visual basic .net

Go to the code page:

Add the following form load event code:

Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        DateTimePicker1.Format = DateTimePickerFormat.Short
        PictureBox1.Image = Nothing
    End Sub

There are two functions that we will add the code page:

Add Process Function to extract the month and day of the date of birth:

Public Function Process(dateOfBirth As Date) As String
        Dim Info As String
        Dim BirthMonth As Integer = dateOfBirth.Month
        Dim BirthDay As Integer = dateOfBirth.Day
        Select Case BirthMonth
            Case 1
                If BirthDay > 19 Then
                    Info = Zodiac(11)
                ElseIf BirthDay < 20 Then
                    Info = Zodiac(10)
                End If
            Case 2
                If BirthDay > 18 Then
                    Info = Zodiac(12)
                ElseIf BirthDay < 19 Then
                    Info = Zodiac(11)
                End If
            Case 3
                If BirthDay > 20 Then
                    Info = Zodiac(1)
                ElseIf BirthDay < 21 Then
                    Info = Zodiac(12)
                End If
            Case 4
                If BirthDay > 19 Then
                    Info = Zodiac(2)
                ElseIf BirthDay < 20 Then
                    Info = Zodiac(1)
                End If
            Case 5
                If BirthDay > 20 Then
                    Info = Zodiac(3)
                ElseIf BirthDay < 21 Then
                    Info = Zodiac(2)
                End If
            Case 6
                If BirthDay > 20 Then
                    Info = Zodiac(4)
                ElseIf BirthDay < 21 Then
                    Info = Zodiac(3)
                End If
            Case 7
                If BirthDay > 22 Then
                    Info = Zodiac(5)
                ElseIf BirthDay < 23 Then
                    Info = Zodiac(4)
                End If
            Case 8
                If BirthDay > 22 Then
                    Info = Zodiac(6)
                ElseIf BirthDay < 23 Then
                    Info = Zodiac(5)
                End If
            Case 9
                If BirthDay > 22 Then
                    Info = Zodiac(7)
                ElseIf BirthDay < 23 Then
                    Info = Zodiac(6)
                End If
            Case 10
                If BirthDay > 22 Then
                    Info = Zodiac(8)
                ElseIf BirthDay < 23 Then
                    Info = Zodiac(7)
                End If
            Case 11
                If BirthDay > 22 Then
                    Info = Zodiac(9)
                ElseIf BirthDay < 23 Then
                    Info = Zodiac(8)
                End If
            Case 12
                If BirthDay > 21 Then
                    Info = Zodiac(10)
                ElseIf BirthDay < 22 Then
                    Info = Zodiac(9)
                End If
        End Select
        Return Info
    End Function

Then add the following function that will define the Zodiac sign and planet info, etc,,,

Public Function Zodiac(id As Integer) As String
        Dim sign As String
        Dim planet As String
        Dim symbol As String
        Dim charas As String
        Select Case id
            Case 1
                sign = "Aries"
                PictureBox1.Image = My.Resources.Aries
                planet = "Mars"
                charas = "Active, Demanding, Determined, Effective, Ambitious"
            Case 2
                sign = "Taurus"
                PictureBox1.Image = My.Resources.Taurus
                planet = "Venus"
                charas = "Security, Subtle strength, Appreciation, Instruction, Patience"
            Case 3
                sign = "Gemini"
                PictureBox1.Image = My.Resources.Gemini
                planet = "Mercury"
                charas = "Communication, Indecision, Inquisitive, Intelligent, Changeable"
            Case 4
                sign = "Cancer"
                PictureBox1.Image = My.Resources.Cancer
                planet = "The Moon"
                charas = "Emotion, Diplomatic, Intensity, Impulsive, Selective"
            Case 5
                sign = "Leo"
                PictureBox1.Image = My.Resources.Leo
                planet = "The Sun"
                charas = "Ruling, Warmth, Generosity, Faithful, Initiative "
            Case 6
                sign = "Virgo"
                PictureBox1.Image = My.Resources.Virgo
                planet = "Mercury"
                charas = "Analyzing, Practical, Reflective, Observation, Thoughtful"
            Case 7
                sign = "Libra"
                PictureBox1.Image = My.Resources.Libra
                planet = "Venus"
                charas = "Balance, Justice, Truth, Beauty, Perfection"
            Case 8
                sign = "Scorpio"
                PictureBox1.Image = My.Resources.Scorpio
                planet = "Pluto"
                charas = "Transient, Self-Willed, Purposeful, Unyielding"
            Case 9
                sign = "Sagittarius"
                PictureBox1.Image = My.Resources.Sagittarius
                planet = "Jupiter"
                charas = "Philosophical, Motion, Experimentation, Optimism"
            Case 10
                sign = "Capricorn"
                PictureBox1.Image = My.Resources.Capricorn
                planet = "Saturn"
                charas = "Determination, Dominance, Perservering, Practical, Willful"
            Case 11
                sign = "Aquarius"
                PictureBox1.Image = My.Resources.Aquarius
                planet = "Uranus"
                charas = "Knowledge, Humanitarian, Serious, Insightful, Duplicitous"
            Case 12
                sign = "Pisces"
                PictureBox1.Image = My.Resources.Pisces
                planet = "Neptune"
                charas = "Fluctuation, Depth, Imagination, Reactive, Indecisive"
        End Select
        Return "Zodiac Sign: " & sign & Environment.NewLine & Environment.NewLine & "Planet: " & planet & Environment.NewLine & Environment.NewLine & "Characteristics: " & charas
    End Function

Then add the following code that will handle the button click event

 Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Dim DOB As Date = DateTimePicker1.Value
        TextBox1.Text = Process(DOB)
    End Sub

a program to get zodiac sign in vb.net

Download source code here


Share This

Subscribe