Home > Enterprise >  visual studio help Visual Basic in the Weekday function?
visual studio help Visual Basic in the Weekday function?

Time:10-20

visual studio help

I have a question about the function: Weekday I want to appear today only in the form through the: Label I tried here but it didn't work: Dim dn As Integer dn = Weekday(Of Date)()

    If dn = 1 Then
        Label61.Text = "Saturday"
    End If
    If dn = 2 Then
        Label61.Text = "Sunday"
    End If
    If dn = 3 Then
        Label61.Text = "Monday"
    End If
    If dn = 4 Then
        Label61.Text = "Tuesday"
    End If
    If dn = 5 Then
        Label61.Text = "Wednesday"
    End If
    If dn = 6 Then
        Label61.Text = "Thursday"
    End If
    If dn = 7 Then
        Label61.Text = "Friday"
    End If

It appears to me that there is an error in the line: Weekday(Of Date)() in : Of dy Please find the solution

CodePudding user response:

You can use DayOfWeek Enum to get week days, Use Today.DayOfWeek to get the week number. If you want to get the week day you can use ToSting method i.e. Today.DayOfWeek.ToString()

  • Related