to : iqds(芊芊) ( ) 我已经新建了picturebox(100) 就是控件数组,如何定义该控件各个控件的click()事件???
'送打开代码 '根据文件路径显示图片 cdgEMP是一个commonDialog控件 Private Sub picEMP_DblClick(index as integer) Dim strFile As String Dim strFilter As String Dim strArr() As String Dim i As Integer Static strPath As String On Error Resume Next If strPath = "" Then strPath = App.Path cdgEMP.DialogTitle = "选择员工照片" strFilter = "图形文件(*.JPG,*.BMP,*.GIF)|*.JPEG;*.JPG;*.BMP;*.GIF" _ & "|所有文件(*.*)|*.*" cdgEMP.Filter = strFilter cdgEMP.InitDir = strPath cdgEMP.FileName = "" cdgEMP.ShowOpen If Err.Number = cdlCancel Then Exit Sub strFile = cdgEMP.FileName If strFile <> "" Then ' mobjMain.Photo = strFile strArr = Split(strFile, "\", , vbTextCompare) strPath = "" For i = 0 To UBound(strArr) - 1 strPath = strPath & strArr(i) Next i Me.picEMP.Picture = LoadPicture(strFile) End If End Sub
body.view =doc.view
载图像文件
形如:
Picture1.Picture=LoadPicture("C:\AAA.BMP")
LoadPicture的具体用法请查阅MSDN
我已经新建了picturebox(100)
就是控件数组,如何定义该控件各个控件的click()事件???
'根据文件路径显示图片
cdgEMP是一个commonDialog控件
Private Sub picEMP_DblClick(index as integer)
Dim strFile As String
Dim strFilter As String
Dim strArr() As String
Dim i As Integer
Static strPath As String
On Error Resume Next
If strPath = "" Then strPath = App.Path
cdgEMP.DialogTitle = "选择员工照片"
strFilter = "图形文件(*.JPG,*.BMP,*.GIF)|*.JPEG;*.JPG;*.BMP;*.GIF" _
& "|所有文件(*.*)|*.*"
cdgEMP.Filter = strFilter
cdgEMP.InitDir = strPath
cdgEMP.FileName = ""
cdgEMP.ShowOpen
If Err.Number = cdlCancel Then Exit Sub
strFile = cdgEMP.FileName
If strFile <> "" Then
' mobjMain.Photo = strFile
strArr = Split(strFile, "\", , vbTextCompare)
strPath = ""
For i = 0 To UBound(strArr) - 1
strPath = strPath & strArr(i)
Next i
Me.picEMP.Picture = LoadPicture(strFile)
End If
End Sub