Foros del Web » Programación para mayores de 30 ;) » Programación General » Visual Basic clásico »

Ayuda con un timer

Estas en el tema de Ayuda con un timer en el foro de Visual Basic clásico en Foros del Web. A mi me da error cuando pongo lo que quiero hacer en este codigo Timer1.enabled = True Timer1.interval = 0 Label88.caption = 0 Private Sub ...
  #1 (permalink)  
Antiguo 11/04/2006, 09:34
XP.
 
Fecha de Ingreso: abril-2006
Mensajes: 51
Antigüedad: 18 años
Puntos: 0
Ayuda con un timer

A mi me da error cuando pongo lo que quiero hacer en este codigo

Timer1.enabled = True
Timer1.interval = 0
Label88.caption = 0
Private Sub Timer1_timer()
Label88.caption = Label88.caption + 1
If label88.caption = 1 then
ACA SE CIERRAN TODAS LAS VENTANAS QUE ESTEN ABIERTAS
end if
If label88.caption = 3 Then
ACA SE EJECUTA EL HL.EXE
end if
If label88.caption = 5 then
ACA SE CIERRA EL HL.EXE
end if
If label88.caption = 7 then
label88.caption = 0
timer1.enabled = False
end if
end sub

para que se ejecute el CS uso la funcion "Shell"

y para cerrar el proceso "hl.exe" usao Killapp "hl.exe" pero no anda
  #2 (permalink)  
Antiguo 11/04/2006, 10:52
Avatar de GeoAvila
Colaborador
 
Fecha de Ingreso: diciembre-2003
Ubicación: Antigua Guatemala
Mensajes: 4.032
Antigüedad: 20 años, 4 meses
Puntos: 53
donde te marca error...???

nos vemos..
__________________
* Antes de preguntar lee las FAQ, y por favor no hagas preguntas en las FAQ
Sitio http://www.geoavila.com twitter: @GeoAvila
  #3 (permalink)  
Antiguo 11/04/2006, 13:02
Avatar de vbx3m  
Fecha de Ingreso: febrero-2005
Ubicación: Venezuela
Mensajes: 524
Antigüedad: 19 años, 3 meses
Puntos: 1
Cita:
Iniciado por XP.
A mi me da error cuando pongo lo que quiero hacer en este codigo

Timer1.enabled = True
Timer1.interval = 0
Label88.caption = 0
Private Sub Timer1_timer()
Label88.caption = Label88.caption + 1
If label88.caption = 1 then
ACA SE CIERRAN TODAS LAS VENTANAS QUE ESTEN ABIERTAS
end if
If label88.caption = 3 Then
ACA SE EJECUTA EL HL.EXE
end if
If label88.caption = 5 then
ACA SE CIERRA EL HL.EXE
end if
If label88.caption = 7 then
label88.caption = 0
timer1.enabled = False
end if
end sub

para que se ejecute el CS uso la funcion "Shell"

y para cerrar el proceso "hl.exe" usao Killapp "hl.exe" pero no anda
Primer el al Timer le debes asignar un intervalo.. si esta en 0 no "corre" el tiempo... Me imagino q lo que quieres hacer con el label88 es un contador...

Prueba asi:

Código:
Dim xseg As Integer
Private Sub Form_Load()
xseg = 0
Timer1.Enabled = True
Timer1.Interval = 1000   'El intervalo de 1 seg
Label88.Caption = 0
End Sub

Private Sub Timer1_timer()
xseg = xseg + 1
Label88.Caption = xseg
If xseg = 1 Then
'ACA SE CIERRAN TODAS LAS VENTANAS QUE ESTEN ABIERTAS
End If
If xseg = 3 Then
'ACA SE EJECUTA EL HL.EXE
End If
If xseg = 5 Then
'ACA SE CIERRA EL HL.EXE
End If
If xseg = 7 Then
   xseg = 0
   Label88.Caption = xseg
   Timer1.Enabled = False
End If
End Sub
__________________
ホルヘ・ラファエル・マルティネス・レオン
  #4 (permalink)  
Antiguo 11/04/2006, 14:29
XP.
 
Fecha de Ingreso: abril-2006
Mensajes: 51
Antigüedad: 18 años
Puntos: 0
Cita:
Private Sub Form_Load()
xseg = 0
Timer1.Enabled = True
Timer1.Interval = 1000 'El intervalo de 1 seg
Label88.Caption = 0
End Sub

Private Sub Timer1_timer()
xseg = xseg + 1
Label88.Caption = xseg
If xseg = 1 Then
'ACA SE CIERRAN TODAS LAS VENTANAS QUE ESTEN ABIERTAS
End If
If xseg = 3 Then
Shell (Text1.Text & " -game cstrike - nomaster - console")
End If
If xseg = 5 Then
Killapp "hl.exe"
End If
If xseg = 7 Then
xseg = 0
Label88.Caption = xseg
Timer1.Enabled = False
End If
End Sub
cuando voy a generar el .EXE me da error, me dice que falta un objeto y me marca en amarillo esto: Label88.Caption = 0
  #5 (permalink)  
Antiguo 11/04/2006, 14:36
Avatar de vbx3m  
Fecha de Ingreso: febrero-2005
Ubicación: Venezuela
Mensajes: 524
Antigüedad: 19 años, 3 meses
Puntos: 1
Quiere decir q estas haciendo referencia a un objeto q no existe... El label88 no existe... Revisa si le cambiaste el nombre o si lo eliminaste....
__________________
ホルヘ・ラファエル・マルティネス・レオン
  #6 (permalink)  
Antiguo 11/04/2006, 14:47
XP.
 
Fecha de Ingreso: abril-2006
Mensajes: 51
Antigüedad: 18 años
Puntos: 0
Cita:
Timer1.Enabled = True
Timer1.Interval = 0
label88.Caption = 0

Private Sub Timer1_timer()
label88.Caption = label88.Caption + 1
If label88.Caption = 1 Then
CERRAR VENTANAS
End If
If label88.Caption = 3 Then
Shell (Text1.Text & " -game cstrike - nomaster - console")
End If
If label88.Caption = 5 Then
Killapp "hl.exe"
End If
If label88.Caption = 7 Then
label88.Caption = 0
Timer1.Enabled = False
End If
End Sub
  #7 (permalink)  
Antiguo 11/04/2006, 14:51
Avatar de vbx3m  
Fecha de Ingreso: febrero-2005
Ubicación: Venezuela
Mensajes: 524
Antigüedad: 19 años, 3 meses
Puntos: 1
Me explico... Estas haciendo referencia al label88 pero en tu formulario no existe el label88... Eso es porq lo eliminaste(no existe) o le cambiaste el nombre... Revisa en tu formulario el nombre del label y lo modificas por el q aparece en el codigo o viceversa... Si no existe lo creas...
__________________
ホルヘ・ラファエル・マルティネス・レオン
  #8 (permalink)  
Antiguo 11/04/2006, 15:11
XP.
 
Fecha de Ingreso: abril-2006
Mensajes: 51
Antigüedad: 18 años
Puntos: 0
acá esta el proyecto http://rapidshare.de/files/17771625/Programa.rar.html
  #9 (permalink)  
Antiguo 12/04/2006, 06:32
Avatar de vbx3m  
Fecha de Ingreso: febrero-2005
Ubicación: Venezuela
Mensajes: 524
Antigüedad: 19 años, 3 meses
Puntos: 1
Aja... pero trata de resolver el porq te arroja un error...
Código:
Timer1.Enabled = True
Timer1.Interval = 0
label88.Caption = 0

Private Sub Timer1_timer()
label88.Caption = label88.Caption + 1
If label88.Caption = 1 Then
CERRAR VENTANAS
End If
If label88.Caption = 3 Then
Shell (Text1.Text & " -game cstrike - nomaster - console")
End If
If label88.Caption = 5 Then
Killapp "hl.exe"
End If
If label88.Caption = 7 Then
label88.Caption = 0
Timer1.Enabled = False
End If
End Sub
Aca estas usando el label88 (q no existe) como contador... y estas asignando el intervalo del timer a 0... Por eso te puse este codigo:

Código:
Dim xseg As Integer
Private Sub Form_Load()
xseg = 0
Timer1.Enabled = True
Timer1.Interval = 1000   'El intervalo de 1 seg
End Sub

Private Sub Timer1_timer()
xseg = xseg + 1
If xseg = 1 Then ACA SE CIERRAN TODAS LAS VENTANAS QUE ESTEN ABIERTAS
If xseg = 3 Then ACA SE EJECUTA EL HL.EXE
If xseg = 5 Then ACA SE CIERRA EL HL.EXE
If xseg = 7 Then
   xseg = 0
   Timer1.Enabled = False
End If
End Sub
Aca el contador es xseg y el intervalo es de 1000 (1 segundo) y las condiciones las especificas de acuerdo al valor del contador...

Ahora te toca resolver el problema...
__________________
ホルヘ・ラファエル・マルティネス・レオン
  #10 (permalink)  
Antiguo 12/04/2006, 06:49
XP.
 
Fecha de Ingreso: abril-2006
Mensajes: 51
Antigüedad: 18 años
Puntos: 0
nose.........
  #11 (permalink)  
Antiguo 12/04/2006, 11:36
XP.
 
Fecha de Ingreso: abril-2006
Mensajes: 51
Antigüedad: 18 años
Puntos: 0
Bueno me di cuenta que no tenia agregada ninguna etiqueta xD

asi que le agregue una con el nombre Label1 quedo asi

Código:
Private Sub Timer1_timer()
Label1.Caption = Label1.Caption + 1
If Label1.Caption = 1 Then
Killapp "cdhack.exe"
End If
If Label1.Caption = 3 Then
Shell (Text1.Text & " -game cstrike - nomaster - console")
End If
If Label1.Caption = 5 Then
Killapp "hl.exe"
End If
If Label1.Caption = 7 Then
Label1.Caption = 0
Timer1.Enabled = False
End If
End Sub
pero se ejecuta al iniciar el programa dandome "error 13 en tiempo de ejecución, no coinciden los tipos "

yo lo que quiero que haga es que al hacer click en el boton de "Jugar CS" que habra el juego y se ejecute el codigo que esta arriba, osea primero que habra el CS normalmente pero que se cierre y se vuelva a abrir en 1.5 segundos.
  #12 (permalink)  
Antiguo 12/04/2006, 13:05
Avatar de vbx3m  
Fecha de Ingreso: febrero-2005
Ubicación: Venezuela
Mensajes: 524
Antigüedad: 19 años, 3 meses
Puntos: 1
Si lo quieres hacer con el label bueno... coloca Label1.Caption=Val(label1.Caption)+1
__________________
ホルヘ・ラファエル・マルティネス・レオン
  #13 (permalink)  
Antiguo 12/04/2006, 13:58
XP.
 
Fecha de Ingreso: abril-2006
Mensajes: 51
Antigüedad: 18 años
Puntos: 0
Cita:
Iniciado por vbx3m
Si lo quieres hacer con el label bueno... coloca Label1.Caption=Val(label1.Caption)+1
Gracias Funciono!

Saludos.
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 02:57.