loadcomponent.vb
来自「《CSDN 开发高手》2004年第6期」· VB 代码 · 共 37 行
VB
37 行
Imports System.Windows.Forms
Public Class LoadComponent
Private myDll As System.Reflection.Assembly
Private obj As Object
Public Function LoadComponentLibrary(ByVal ComponentFileName As String) As Boolean
'装入指定的组件代码库
'成功返回true
Try
myDll = System.Reflection.Assembly.LoadFrom(ComponentFileName)
If myDll Is Nothing Then
MessageBox.Show("Can't Load library")
Return False
End If
Catch Errobj As SystemException
MessageBox.Show(Errobj.Message)
Return False
End Try
Return True
End Function
Public Function LoadClass(ByVal classname As String) As Object
If myDll Is Nothing Then
Return Nothing
End If
Try
obj = myDll.CreateInstance(classname)
Catch Errobj As SystemException
MessageBox.Show(Errobj.Message)
Return Nothing
End Try
Return obj
End Function
End Class
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?