在Form_load中加载,运行后不能在控件数组中显示图片,
我把Form_load中的代码放在Form_click 中,运行点击窗体后却可以得到相应的结果请大家帮忙下~谢谢
Option ExplicitPrivate Declare Function DrawIcon Lib "user32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal hIcon As Long) As LongPrivate Declare Function ExtractIcon Lib "shell32.dll" Alias "ExtractIconA" (ByVal hInst As Long, ByVal lpszExeFileName As String, ByVal nIconIndex As Long) As LongPrivate Declare Function WaitForSingleObject Lib "kernel32" _
        (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
    
Private Declare Function CloseHandle Lib "kernel32" _
        (ByVal hObject As Long) As Long
          
Private Declare Function OpenProcess Lib "kernel32" _
        (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, _
          ByVal dwProcessId As Long) As LongPrivate Sub Form_Load()
  Dim conn As New ADODB.Connection
    Dim rs As New ADODB.Recordset
    Dim p As Long
    Dim getThefile As String
    Dim i As Integer
    i = 1
    '使用数据源来连接数据库
    conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + App.path & "\menu.mdb" + ";Persist Security Info=False"
    rs.Open "select * from menu", conn  '显示结果
    rs.MoveFirst
    While (Not rs.EOF)
        getThefile = rs.Fields(3)
            If ExtractIcon(App.hInstance, getThefile, -1) = 0 Then
                GoTo MyErr
            Else
                p = ExtractIcon(App.hInstance, getThefile, 0)
                DrawIcon Picture1(i).hdc, 0, 0, p
            End If        i = i + 1
        rs.MoveNext
     Wend
MyErr:
             MsgBox "No Icon"
End Sub