LoginSignup
1
0

More than 5 years have passed since last update.

Class内での定数の宣言の仕方

Posted at

VBScriptのClass内で、PrivateなConst定数を宣言したかったのですが、
以下のような書き方だとエラーになってしまう。

Class Book
  ' エラー
  ' Private Const Title = "..."
End Class

これの解決策は、Getterのみのプロパティを宣言すれば出来た。

Class Book
  Private Property Get Title()
    Title = "..."
  End Property
End Class

Dim bk
Set bk = New Book
WScript.Echo bk.Title

' Setterがないのでエラー
' bk.Title = "..." 

Set bk = Nothing      
1
0
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
0