Const strWeekdays = "1:月:MON:Mon:Monday,2:火:TUE:Tue:Tuesday,3:水:WED:Wed:Wednesday,4:木:THU:Thu:Thursday,5:金:FRI:Fri:Friday,6:土:SAT:Sat:Saturday,7:日:SUN:Sun:Sunday" Const vbWq = """" Public strWeekday Dim varNow, VarDate, sDa, sDb, sDc, sDd, sDe, testResult varNow = Now() varDate = Date() strWeekday = GetWeekday(varDate,,strWeekdays,3) sDa = iDTw(varDate,varNow,"YMD [W] HN","/",":",,0) sDb = iDTw(varDate,varNow,"YMD",,,,0) sDc = iDTw(,,"YMD*[W]*HNS",,,"*",1) sDd = iDTw(,,"YMDWHNS","",""," ",0) sDe = iDTw(,,"YMD [ W ] HNS","",""," ",0) testResult = "iDTw(" & "varDate,varNow," & vbWq & "YMD [W] HN" & vbWq & "," & vbWq & "/" & vbWq & "," & vbWq & ":" & vbWq & ",,0) - <String YMD[W]HN> - >>> " & sDa & vbTab & vbCrLf _ & "iDTw(" & "varDate,varNow," & vbWq & "YMD" & vbWq & ",,,,0) - <String YMD Only> - >>> " & sDb & vbTab & vbCrLf _ & "iDTw(" & ",," & vbWq & "YMD*[W]*HNS" & vbWq & ",,," & vbWq & "*" & vbWq & ",1) - <Array iDTw(1)> - >>> " & sDc(1) & vbTab & vbCrLf _ & "iDTw(" & ",," & vbWq & "YMDWHNS" & vbWq & "," & vbWq & vbWq & "," & vbWq & vbWq & "," & vbWq & " " & vbWq & ",0) - <String NoSplitter> - >>> " & sDd & vbTab & vbCrLf _ & "iDTw(" & ",," & vbWq & "YMD [ W ] HNS" & vbWq & "," & vbWq & vbWq & "," & vbWq & vbWq & "," & vbWq & " " & vbWq & ",0) - <String Full> - >>>" & sDe & vbTab msgbox testResult,,"Test" Function GetWeekday(YMD,wFormat,WeekdaysString,nDepth) Dim arsWeekdays,arWeekdays If TypeName(WeekdaysString) = "Error" Then ElseIf VarType(arWeekdays) = vbArray Then Else inArrays WeekdaysString,",:",arWeekdays End If If TypeName(wFormat) = "Error" Then GetWeekday = arWeekdays(Weekday(YMD,2) - 1)(nDepth) Else GetWeekday = Replace(wFormat,"W",arWeekdays(Weekday(YMD,2) - 1)(nDepth)) End If End Function Function iDTw(tDate,tNow,sFormat,dSplitter,tSplitter,dtSeparator,Control) Dim nS, strHNS, arHNS, iHNS, valHNS If TypeName(tDate) = "Error" Then tDate = Date() End If If TypeName(tNow) = "Error" Then tNow = Now() End If If TypeName(dSplitter) = "Error" Then dSplitter = "/" End If If TypeName(tSplitter) = "Error" Then tSplitter = ":" End If If TypeName(Control) = "Error" Then Control = 0 End If If TypeName(dtSeparator) = "Error" Then If Control = 1 Then dtSeparator = "*" Else dtSeparator = " " End If End If strS = Split(CStr(FormatDateTime(tNow,3)),":")(2) strHN = FormatDateTime(tNow,4) strHNS = FormatDateTime(tNow,4) & tSplitter & strS If TypeName(sFormat) = "Error" Then sFormat = "YMD" & dtSeparator & "HNS" End If If dSplitter = "/" Then Else tDate = Replace(tDate,"/",dSplitter) End If If tSplitter = ":" Then Else strHNS = Replace(strHNS,":",tSplitter) End If sFormat = Replace(sFormat,"YMD",tDate) sFormat = Replace(sFormat,"HNS",strHNS) sFormat = Replace(sFormat,"HN",strHN) sFormat = Replace(sFormat,"S",strS) If TypeName(sFormat) = "Error" Then Else wExist = Instr(1,sFormat,"W",1) If wExist = 0 Then Else sFormat = Replace(sFormat,"W",strWeekday) End If End If If Control = 0 Then iDTw = sFormat Else iDTw = Split(sFormat,dtSeparator) End If End Function Function lArray(strLetters, rArray) Dim Pc, rLetters() Set objADO = CreateObject("ADODB.Stream") With objADO .Type = 2 .Open .WriteText strLetters Pc = 0 .Position = 0 Do Until .EOS ReDim Preserve rLetters(Pc) rLetters(Pc) = .ReadText(1) Pc = Pc + 1 Loop End With rArray = rLetters objADO.Close Set objADO = Nothing End Function Function inArrays(tSources, strLimitters, arReturn) Dim arSources, arLimitters, iLimitter, arInArrays, iSource, Pc arSources = tSources lArray strLimitters, arLimitters For Each iLimitter In arLimitters If VarType(arSources) = 8 Then arInArrays = Split(arSources,iLimitter) Else Pc = 0 ReDim arInArrays(0) For Each iSource in arSources ReDim Preserve arInArrays(Pc) arInArrays(Pc) = Split(iSource,iLimitter) Pc = Pc + 1 Next End If arSources = arInArrays arInArrays = Null Next arReturn = arSources End Function
|
0 件のコメント:
コメントを投稿
注: コメントを投稿できるのは、このブログのメンバーだけです。