「Excel VBA Log Utility」の版間の差分
ナビゲーションに移動
検索に移動
(ページの作成:「==Excel VBA Log Utility== [Excel VBA]{{category VBAソース片}} [Excel VBA File Utility] [FileUtil.cls]を使用 *Excel VBA File Utility ==='''Log.bas'''=== Opt…」) |
|||
(同じ利用者による、間の3版が非表示) | |||
1行目: | 1行目: | ||
− | ==Excel VBA Log Utility== | + | ==[[Excel VBA Log Utility]]== |
− | [Excel VBA] | + | [[Excel VBA]] | [[Category:VBAソース片]] |
− | [Excel VBA File Utility | + | [[Excel VBA File Utility|FileUtil.cls]]を使用 |
− | *Excel VBA File Utility | + | *[[Excel VBA File Utility]] |
==='''Log.bas'''=== | ==='''Log.bas'''=== | ||
Option Explicit | Option Explicit | ||
71行目: | 71行目: | ||
End Function | End Function | ||
' | ' | ||
− | ' | + | ' [[タイムスタンプ]]文字列生成 |
' | ' | ||
− | ' @return | + | ' @return [[タイムスタンプ]]文字列生成 "YYYY/MM/DD HH:MM:SS" |
' | ' | ||
− | Private Function | + | Private Function get[[TimeStamp]]() As String |
− | + | get[[TimeStamp]] = Date & " " & Time | |
End Function | End Function | ||
{{ref Log.bas}} | {{ref Log.bas}} |
2020年2月16日 (日) 04:25時点における最新版
Excel VBA Log Utility
FileUtil.clsを使用
Log.bas
- Option Explicit
- '
- Private log As FileUtil
- Private m_IsOpen As Boolean
- '
- ' ログの初期化
- '
- ' @param fileName 出力先ファイル
- '
- Public Sub initialLog(fileName As String)
- m_IsOpen = False
- Set log = New FileUtil
- m_IsOpen = log.openFile(fileName, FileMode.AppendMode)
- End Sub
- '
- ' ログの解放
- '
- Public Sub terminateLog()
- Call log.closeFile
- m_IsOpen = False
- Set log = Nothing
- End Sub
- '
- ' [INFO] ログの出力
- '
- ' @param str メッセージ
- '
- Public Sub info(str As String)
- If Not isWritable() Then
- Exit Sub
- End If
- Call log.println(getTimeStamp & "[INFO] " & str)
- End Sub
- '
- ' [ERROR] ログの出力
- '
- ' @param str メッセージ
- '
- Public Sub error(str As String)
- If Not isWritable() Then
- Exit Sub
- End If
- Call log.println(getTimeStamp & "[ERROR] " & str)
- End Sub
- '
- ' ログが書き込み可能か否か
- '
- ' @param str メッセージ
- '
- Private Function isWritable() As Boolean
- isWritable = (m_IsOpen And log.isOpen)
- End Function
- '
- ' タイムスタンプ文字列生成
- '
- ' @return タイムスタンプ文字列生成 "YYYY/MM/DD HH:MM:SS"
- '
- Private Function getTimeStamp() As String
- getTimeStamp = Date & " " & Time
- End Function
© 2006 矢木浩人