VB.net 2010 视频教程 VB.net 2010 视频教程 python基础视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > VB.net教程 >
  • VB.net根据类的名字动态使用某个类

Public Class MyForm
Inherits System.Collections.CollectionBase
Private Lists() As FormIndexAndName
Default Public ReadOnly Property Item(ByVal Name As String) As System.Windows.Forms.Form
Get
Dim i As Int32
For i = 0 To Lists.Length - 1
With Lists(i)
If .Name = Name Then
Return Me.List.Item(.Index)
End If
End With
Next
Return Nothing
End Get
End Property

Public Sub AddItem(ByVal btnItem As System.Windows.Forms.Form, Name As String)
    ReDim Preserve Lists(Lists.Length)
    Lists(Lists.Length).Name = Name
    Lists(Lists.Length).Index = Me.List.Count
    Me.List.Add(btnItem)
End Sub

Private Structure FormIndexAndName
    Dim Index As Int32
    Dim Name As String
End Structure

Sub New()
    ReDim Lists(-1)
End Sub

End Class

这个应该能解决你的问题


相关教程