Visual Basic Foro
Programación => Visual Basic 6 => Mensaje iniciado por: lucius en Noviembre 28, 2011, 08:11:13 pm
-
Quiero cargar una imagen de equiz extencion .bmp . jpg etc atravez del nombre pero el problema esta ahi osea si intento cargar imagen.bmp y el archivo se llama imagen.jpg entonces me tira error.
Actualmente lo hago asi pero hay algun otro metodo o como lo hago correctamente.
Private Declare Function PathFileExists Lib "shlwapi.dll" Alias "PathFileExistsA" (ByVal pszPath As String) As Long
Private Sub Command1_Click()
If CStr(CBool(PathFileExists(App.Path & "\xarchivo.jpg"))) = True Then
MsgBox "existe xarchivo.jpg"
ElseIf CStr(CBool(PathFileExists(App.Path & "\xarchivo.bmp"))) = True Then
MsgBox "existe xarchivo.bmp"
ElseIf CStr(CBool(PathFileExists(App.Path & "\xarchivo.gif"))) = True Then
MsgBox "existe xarchivo.gif"
Else
MsgBox "no existe ningun archivo del tipo imagen"
End If
End Sub
-
ese CStr() no es necesario. hay varias formas GetAttr() o estas:
Como verificar si un archivo existe (http://www.recursosvisualbasic.com.ar/htm/trucos-codigofuente-visual-basic/164-verificar-si-archivo-existe.htm#1)
saludos.
-
HOLA!!!
La mas facil (no la mas rapida).
Private Sub FileExist(Path as string) as boolean
if Len(dir( Path) ) > 0 then FileExist = True
GRACIAS POR LEER!!!