Thursday, 29 March 2018

Program to Display Day of the Week using if elseif statement in VB 2010


Public Class Form1
    Dim day As Integer
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmddisp.Click
        day = txtday.Text
        If (day = 1) Then
            lbloutput.Text = "Monday"
        ElseIf (day = 2) Then
            lbloutput.Text = "Tuesday"
        ElseIf (day = 3) Then
            lbloutput.Text = "Wednesday"
        ElseIf (day = 4) Then
            lbloutput.Text = "Thursday"
        ElseIf (day = 5) Then
            lbloutput.Text = "Friday"
        ElseIf (day = 6) Then
            lbloutput.Text = "Saturday"
        ElseIf (day = 7) Then
            lbloutput.Text = "Sunday"
        Else
            lbloutput.Text = "There are only 7 days in a week"

        End If

    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.