Visual Basic 中学校 > Visual Basic サンプル集 > Visual Basic サンプル集目次 >
クラス名を取得する
1.完全限定名を取得する
完全限定名とは名前空間を含むクラス名でSystem.Windows.Forms.Buttonのような形式を指す。
以下の例ではButton型の変数から完全限定名を取得する。
Dim MyButton As New Button
Dim StrictName As StringStrictName = MyButton.GetType.FullName
MsgBox(StrictName) 'System.Windows.Forms.Button等
以下の例ではクラスの型から完全限定名を取得する。
Dim StrictName As String StrictName = GetType(Button).FullName
MsgBox(StrictName) 'System.Windows.Forms.Button等
2.単純な名前を取得する
以下の例では現在のクラスの名前を取得する。
Dim ThisName As String ThisName = Me.GetType.Name
MsgBox(ThisName) 'Form1等