Subway Surfers Cheat Codes Codes and Tips Free Get Started Codes and Secrets Information Subway Surfers Tips and Cheats Subway Surfers .
Download Subway Surfers for Android? - Android Hints .Q:
Get only Day of the Week from date in vba code
I've created a code in VBA for a certain task. I need help to achieve what I want to do.
What I've been looking for so far is a code that returns only the day of the week from a Date that is given in a variable.
The Code:
Dim day1 As String
day1 = Format(Date, "dd")
'For every day, print "my text"
If day1 = "Monday" Then
MsgBox "Your text"
End If
The desired result:
If day1 = "Monday" Then
MsgBox "Your text"
End If
The result from the code above:
MsgBox "Your text"
The result I'd like to have:
MsgBox "Your text"
Any help would be appreciated.
A:
By simple check, if the day of the week is Monday, then you'll get a MessageBox. If it's not, no MsgBox appears. This is how you'd get that "desired result":
Dim day1 As String
If Day(Date) = 1 Then
day1 = "Monday"
ElseIf Day(Date) = 2 Then
day1 = "Tuesday"
ElseIf Day(Date) = 3 Then
day1 = "Wednesday"
ElseIf Day(Date) = 4 Then
day1 = "Thursday"
ElseIf Day(Date) = 5 Then
day1 = "Friday"
ElseIf Day(Date) = 6 Then
day1 = "Saturday"
ElseIf Day(Date) = 7 Then
day1 = "Sunday"
End If
MsgBox "Your text" & vbNewLine & day1
Note that if you ever want to see a MessageBox, you'll need to use the MsgBox command, not MsgBox.
Comparison of the effect be359ba680
Related links:
Коментари