Tuesday, 3 April 2018

Display Month of the Year using Select Case in VB 2010

Public Class Form1
    Dim n As Integer
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdClick.Click
        n = txtEnter.Text
        Select Case n
            Case 1
                lblOUTPUT.Text = "1st Month is January"
            Case 2
                lblOUTPUT.Text = "2nd Month is February"
            Case 3
                lblOUTPUT.Text = "3rd Month is March"
            Case 4
                lblOUTPUT.Text = "4th Month is April"
            Case 5
                lblOUTPUT.Text = "5th Month is May"
            Case 6
                lblOUTPUT.Text = "6th Month is June"
            Case 7
                lblOUTPUT.Text = "7th Month is July"
            Case 8
                lblOUTPUT.Text = "8th Month is August"
            Case 9
                lblOUTPUT.Text = "9th Month is September"
            Case 10
                lblOUTPUT.Text = "10th Month is October"
            Case 11
                lblOUTPUT.Text = "11th Month is November"
            Case 12
                lblOUTPUT.Text = "12th Month is December"

            Case Else
                lblOUTPUT.Text = "There are only 12 months in a year"

        End Select
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class

No comments:

Post a Comment

Note: only a member of this blog may post a comment.