因工作中,需要在系统里加入378张图片,第一次用的是直接加入的方法,弄得程序一下子由2M猛增到180M,这明显不行,这几天在这里学了引用外部图片方法,这方法固然好,但得注意:《一》1、图片与程序同文件夹时;2、图片与程序不同文件夹时代码是不一样的,如
Private Sub Form_Current()
Dim strPath As String
strPath = CurrentProject.Path & "\器材图片" & Me.图片地址 & ".jpg"
If Dir(strPath) <> "" Then
Me.照片.Picture = strPath
Else
Me.照片.Picture = ""
End If
End Sub
与
Private Sub Form_Current()
Dim strPath As String
strPath = CurrentProject.Path & "\" & Me.图片地址 & ".jpg"
If Dir(strPath) <> "" Then
Me.照片.Picture = strPath
Else
Me.照片.Picture = ""
End If
End Sub
这两代码段只差别于& "\器材图片" & 与& "\" & ,前为2、图片与程序不同文件夹时,后为1、图片与程序同文件夹时。
《二》、是异码同功
Private Sub Form_Current()
Dim strPath As String
strPath = CurrentProject.Path & "\器材图片\" & Me.图片地址
If Dir(strPath) <> "" Then
Me.Image4.Picture = strPath
Else
Me.Image4.Picture = ""
End If
End Sub
与
Private Sub Form_Current()
Me.Image4.Picture = CurrentProject.Path & "\器材图片\" & Me.图片地址
End Sub
同功!!
为了方便与我一样的初学者,在上传的附件中,特设了同功而异码的两个窗体命曰图片显示1与图片显示2。
但有一个与这有关的问题还没有解决,就是当图片与程序分别在不同文件夹时,还没有找到解决办法,望高手赐教,谢谢!!