imgPhoto.picture=loadpicture(filename)

解决方案 »

  1.   

    谢谢了
    我是在点击COMMAND就能打开文件,希望选择文件后就能显示在IMAGE上。能具体点吗?谢谢了
      

  2.   

    Dim strPhoto As String
    On Error GoTo cmdLoad_Click_EH
    ' 先行记录原始 txtPhoto 的字串。
    If txtPhoto <> "" Then
        strPhoto = txtPhoto.Text
    Else
        strPhoto = ""
    End If
        
    With dlgOpen
        .CancelError = True
        .Filter = "所有图形文件 (*.bmp;*.ico;*.wmf;*.jpg;" _
                & "*.gif)|*.bmp;*.wmf;*.jpg;*.gif|位图 (*.bmp)" _
                & "|*.bmp|WMF文件 (*.wmf)|" _
                & "*.wmf|Jpeg文件 (*.jpg)|*.jpg|Gif文件 (*.gif)|" _
                & "*.gif|所有文件 (*.*)|*.*"
        .Flags = cdlOFNExplorer Or _
                 cdlOFNFileMustExist Or cdlOFNHideReadOnly Or _
                 cdlOFNNoLongNames Or cdlOFNPathMustExist
            .ShowOpen
        End With
        
        ' .FileName为完整路径
        imgMaterial.Picture = LoadPicture(dlgOpen.FileName)
                
        ' 档案名称,但不含路径名。
        txtPhoto.Text = dlgOpen.FileTitle
        
        Exit Sub
    cmdLoad_Click_EH:
        If Err.Number = cdlCancel Then              ' 按下cancel键的处理。
            txtPhoto = strPhoto
        Else
            Beep
            MsgBox Err.Description, vbExclamation, "无法载入图形文件"
        End If
      

  3.   

    别忘了在FORM上添加COMMONDIALOG图标悾件