I'm trying to save a list of image names and then open them, but it does not work.
"For now, just open an image of each guide."
You can help me, this is my code.
Public Function ObtenerImagePath(id As Long) As String
Dim rtn As String
Dim ctrl As New SqliteHelper
Dim rs As cRecordset
Dim query As String
Dim unaimagen As String
Dim variasimagenes As String
query = "SELECT * FROM IMEI WHERE Codigo = " & CStr(id) & ";"
Set rs = ctrl.ExecuteRecordset(query)
If (Not rs.EOF) Then
Dim guia As String
Dim fecha As String
Dim tmp() As String
guia = Trim(rs("Guia"))
fecha = rs("FechaEmi")
tmp = Split(fecha, "/")
unaimagen = Dir(cdPhysicalPath & "Imagenes\" & tmp(2) & tmp(1) & "\" &
guia & ".*")
variasimagenes = Dir(cdPhysicalPath & "Imagenes\" & tmp(2) & tmp(1) &
"\" & guia & "_*") 'Aqui deberia guardar varios nombres de imagen o algo
'así. ejemplo.
'"013406617__1212.TIF","013406617__copia1.TIF","013406617__copia2.TIF".
If Len(unaimagen) > 0 Then
rtn = cdPhysicalPath & "Imagenes\" & tmp(2) & tmp(1) & "\" & unaimagen
ElseIf Len(variasimagenes) > 0 Then
rtn = cdPhysicalPath & "Imagenes\" & tmp(2) & tmp(1) & "\" &
variasimagenes
Else
rtn = ""
End If
End If
ObtenerImagePath = rtn '--> Aquí es donde debería alojar los nombres
'de imagen y abrirlos.
End Function
And this code, shows the image:
Private Sub btnVer_Click()
On Error GoTo btnVer_error
Dim id As Long
id = ObtenerIdSeleccionado()
If (id <= 0) Then
MsgBox "Seleccione un registro.", vbInformation, "INFO"
Exit Sub
End If
If (Not ValidInCD(id)) Then
Exit Sub
End If
Dim path As String
path = ObtenerPath(id)
If (Dir(path) <> "") Then
'Dim f As New FrmImagen
'f.PhysicalPath = path
'f.Show True, Me
'Shell path 'ShellExecute hWnd, "open", path, vbNullString,
vbNullString, SW_SHOWNORMAL
Debug.Print ShellExecute(hWnd, "open", path, vbNullString, vbNullString,
1)
Else
MsgBox "La imagen no existe.", vbInformation + vbOKOnly, "INFO"
End If
Exit Sub
btnVer_error:
MsgBox "No se encontró la imagen.", vbInformation + vbOKOnly, "INFO"
End Sub