ヘッダー

VB.NET2002対応 VB.NET2003対応 VB2005対応

 

クラス名を取得する

1.完全限定名を取得する

完全限定名とは名前空間を含むクラス名でSystem.Windows.Forms.Buttonのような形式を指す。

以下の例ではButton型の変数から完全限定名を取得する。

VB.NET2002対応 VB.NET2003対応 VB2005対応

Dim MyButton As New Button
Dim StrictName As
String

StrictName = MyButton.GetType.FullName

MsgBox(StrictName) 'System.Windows.Forms.Button等

 

以下の例ではクラスの型から完全限定名を取得する。

VB.NET2002対応 VB.NET2003対応 VB2005対応

Dim StrictName As String

StrictName = GetType(Button).FullName

MsgBox(StrictName) 'System.Windows.Forms.Button等

 

2.単純な名前を取得する

 

以下の例では現在のクラスの名前を取得する。

VB.NET2002対応 VB.NET2003対応 VB2005対応

Dim ThisName As String

ThisName = Me.GetType.Name

MsgBox(ThisName) 'Form1等


VB6対応  VB6ではTypeName関数を使用します。型から直接型名を取得することはできません。