Visual Basic - Problema al crear y verificar si existe un fichero urge

Life is soft - evento anual de software empresarial
 
Vista:

Problema al crear y verificar si existe un fichero urge

Publicado por fajardo (9 intervenciones) el 16/10/2011 01:13:36
cuando le doi a crear fichero
Private Sub cmdverificausuario_Click()

Savefile = FreeFile
Nombre = "C:\" & lblusuario.Caption
Open Nombre For Output As #Savefile
Print #Savefile, lblusuario.Caption
Close #Savefile


End Sub
melo crea pero cuando doi a verificar

Private Sub cmdverifica_Click()
GetAttr ("C:\" & lblusuario.Caption)
MsgBox "El fichero existe."
Exit Sub
MsgBox "El fichero no existe."
end sub
me da error por cierto se podria acer que creara el fichero cuando entre el el form o por ejemplo cuando pasen 5 segundos de aver cargado.... gracias
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

Problema al crear y verificar si existe un fichero urge

Publicado por XHkrElite (518 intervenciones) el 16/10/2011 06:51:05
intenta esto fajardo:
ve a Project\References\Microsoft Scripting Runtime
inserta un timer1

luego pon esto en declaraciones
private fso as filesystemobject

Private Sub Form_Load()
set fso = new filesystemobject
End Sub

Private Sub cmdverificausuario_Click()
open "C:\" & lblusuario for output as #1
print #1, "Hola soy " & lblusuario
close #1
timer1.enabled = true
timer1.interval = 5000 '5 segundos
cmdverifica_Click
End Sub

Private Sub cmdverifica_Click()
if fso.fileexists("c:\" & lblusuario) = true then
msgbox "El archivo fue creado"
elseif fso.fileexists ("c:\" & lblusuario) = false then
msgbox "archivo no creado"
end if
end sub
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar