1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

VBScript で C言語風に外部ライブラリ(.vbs)を読み込む

Last updated at Posted at 2024-01-18

以下の例は、[C:\VBScript\Module]フォルダに保存されている[DateModule.vbs]を読み込む.

IncludeLikeC.vbs
Include "DateModule"

WScript.Echo DateFormat(Date, "yyyymmdd")
Function Include(ByVal mod_name)
    Dim modFolderPath
    modFolderPath = "C:\VBScript\Module"
    With CreateObject("Scripting.FileSystemObject")
        With .OpenTextFile(.BuildPath(modFolderPath, mod_name & ".vbs"))
            ExecuteGlobal .ReadAll
            .Close
        End With
    End With
End Function

※ ExecuteGlobal .ReadAll の部分で『')' がありません』というエラーが出る場合、読み込む外部ファイルのコードに問題(スペルミスやUTF8保存など)があるケースが多い。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?