Hack x Crack - Comunidad de Seguridad informática
Programación => Visual Basic => Mensaje iniciado por: Darckz en Abril 02, 2011, 08:07:27 pm
-
Buenas tardes,
mi problema es el siguiente:
pasa que yo le pedi a mi programa que cuando pasaran 10 segundos se ejecutara un pad con mi ip , pero no se ejecuta mi pad , este el codigo:
__________________________________________
Variable:
Dim ti
__________________________________________
Private Sub Command1_Click()
ti = ti + 1
Label1.Caption = ti
If ti = 10 Then
Open ("ip.txt") For Output As #5
Print #5, Winsock1.LocalIP
Close #5
End If
End Sub
_________________________________________
Private Sub Form_Load()
ti = 0
Timer1.Interval = 1000
End Sub
_________________________________________
Private Sub Label1_Click()
End Sub
_________________________________________________
Private Sub Timer1_Timer()
Call Command1_Click
End Sub
__________________________________________________
Private Sub Winsock1_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
End Sub
___________________________________________________
Saludos darckz
-
si solo modifico el "IF" y abajo de then le pongo shell ("cmd.exe") por ejemplo me lo abre sin problema pero si pongo open ("asd.txt") for output as #1
print #1, "asd"
Close #1
end if
____
no me abre la nota y ni me hace el programa :( (OSEA NO ME CREA UN .TXT).
-
Con la linea "Open ("ip.txt") For Output As #5" lo que hace es crear el archivo ip.txt en la ruta del programa (lo carga en memoria pero no lo ejecuta). Para que te abra el notepad tienes que agregar la linea "Shell ("notepad.exe " & App.Path & "\ip.txt"), vbNormalFocus". Aqui te dejo el código acabado:
Dim ti As Integer
Private Sub Command1_Click()
ti = ti + 1
Label1.Caption = ti
If ti = 10 Then
Open "ip.txt" For Output As #5
Print #5, Winsock1.LocalIP
Close #5
Shell ("notepad.exe " & App.Path & "\ip.txt"), vbNormalFocus ' linea para ejecutar el pad
End If
End Sub
Private Sub Form_Load()
ti = 0
Timer1.Interval = 1000
End Sub
Private Sub Timer1_Timer()
Call Command1_Click
End Sub
PD: Es preferible declarar las variables con el tipo de valor que es, por ejemplo "dim val as string" (sustituyendo string por el tipo de dato que necesites: string, integer, long, boolean...).
-
Gracias Kpo (+100)