The VBA WEEKDAY function is listed under the date category of VBA functions. When you use it in a VBA code,it returns the day number (ranging from 1 to 7)by using the number of the day from the supplied date. In simple words, it returns the number of days within the week. Syntax ...
Public Function YearStart(WhichYear As Integer) As Date Dim WeekDay As Integer Dim NewYear As Date NewYear =DateSerial(WhichYear, 1, 1) WeekDay =(NewYear - 2) Mod 7 If WeekDay < 4 Then YearStart = NewYear - WeekDay Else YearStart = NewYear - WeekDay + 7 End If End Function ...
'获取星期的显示Functiondisp(iAsInteger)SelectCaseiCase1disp="一"Case2disp="二"Case3disp="三"Case4disp="四"Case5disp="五"Case6disp="六"CaseElsedisp="日"EndSelectEnd Function'获取当月的天数FunctionGetDaysOfMonth(YearAsString,MonthAsString)AsIntegerDimDay1, Day2AsStringIfMonth="12"ThenGetDays...
Day(date) 返回一个 Variant (Integer),其值为 1 到 31 之间的整数,表示一个月中的某一日 Month(date) 返回一个 Variant (Integer),其值为 1 到 12 之间的整数,表示一年中的某月 Year(date) 返回 Variant (Integer),包含表示年份的整数。 Weekday(date, [firstdayofweek]) 返回一个 Variant (Integer),...
ActiveSheet.[B1].Value="星期"& disp(Weekday(DateStr, vbMonday))'设置单元格行列宽高自适应ActiveSheet.[A1].Columns.AutoFit ActiveSheet.[A1].Rows.AutoFit ActiveSheet.[B1].Columns.AutoFit ActiveSheet.[B1].Rows.AutoFitNextNextSheets(OriginSheet).DeleteOnErrorResumeNextApplication.DisplayAlerts=TrueEnd Su...
To determine the weekday of a date (from 1 to 7) or display it as a text format (Monday-Sunday, MON-SUN, M-S, etc.), there are several options available.To obtain the weekday number of a date (from 1 to 7), simply use the Weekday function:Sub example() dateTest = CDate("...
Weekday(date, [firstdayofweek]) 返回一个Variant (Integer),包含一个整数,代表某个日期是星期几 MsgBox的参数及用法 在消息框中显示信息,并等待用户单击按钮,可返回单击的按钮值(比如“确定”或者“取消”)。通常用作显示变量值的一种方式。 语法 MsgBox(Prompt[,Buttons][,Title][,Helpfile,Context]) ...
msgbox("Line 1 : " & MonthName(01,True)) msgbox("Line 2 : " & MonthName(01,false)) Weekday(date[,firstdayofweek]) '返回一个从1到7的整数,表示指定日期的星期几。 msgbox("Line 1: " & Weekday("2013-05-16",1)) WeekdayName(weekday[,abbreviate[,firstdayofweek]]) '返回指定日期的工作...
Type TIME_OF_DAY_INFOtod_elapsedt As Longtod_msecs As Longtod_hours As Longtod_mins As Longtod_secs As Longtod_hunds As Longtod_timezone As Longtod_tinterval As Longtod_day As Longtod_month As Longtod_year As Longtod_weekday As Long...
Weekday(date, [firstdayofweek]) 返回一个 Variant (Integer),包含一个整数,代表某个日期是星期几 第十三节 文件操作 文件 Dir[(pathname[, attributes])] ; pathname 可选参数,用来指定文件名的字符串表达式,可能包含目录或文件夹、以及驱动器。如果没有找到 pathname,则会返回零长度字符串 (""); ...