Bienvenido: ( Identificarse | Registrarse )      
Foros de Trucos Windows
 
Closed TopicStart new topicStart Poll

Outline · [ Estándar ] · Lineal+

> Chat IP

mario16392
post Feb 10 2008, 12:49 AM
Publicado: #1


Maestro Arquitecto
******

Grupo: Members
Mensajes: 566
Registrado: 6-July 06
Miembro nº: 172.974



Estoy haciendo un programilla para chatear atraves de ip pero no se como hacer para que junto con el mensaje que recibe el receptor apareza la hora a la que ha llegado

y otra cosa... como poner la hora del pc en el programa


este es el codigo:

CODE
Dim BanderaConectado As Boolean
Dim Indice(1 To 1000) As Boolean
Dim Form As New Form1
Dim Posicion As Double

Private Sub CmdConectar_Click()
   Call Conexion
   TxtMensaje.SetFocus
End Sub

Private Sub CeroIndice()
   Dim cont As Integer
   For cont = 1 To 1000
       Indice(cont) = False
   Next cont
End Sub

Private Sub Conexion()
   WSCEnvia.RemoteHost = TxtIp
   WSCEnvia.RemotePort = 49577
   WSCEnvia.Connect
   BanderaConectado = True
   TxtIp.Enabled = False
   CmdConectar.Enabled = False
   CmdDesconectar.Enabled = True
   If WSCEnvia.State = sckConnecting Then
       Form1.Caption = WSCEnvia.LocalIP & " - " & "Conectando..."
   End If
End Sub

Private Sub CmdDesconectar_Click()
   CmdConectar.Enabled = True
   TxtIp.Enabled = True
   CmdDesconectar.Enabled = False
   WSCEnvia.Close
End Sub

Private Sub CmdEnviar_Click()
   Call Envio
End Sub

Private Sub Envio()
   Dim Cadena As String
   If TxtMensaje.Text <> "" Then
       If WSCEnvia.State = sckConnected Then
           WSCEnvia.SendData TxtMensaje.Text
           Posicion = Posicion + Len(TxtMensaje.Text) + 2
           TxtTexto.Text = TxtTexto.TextRTF
           TxtTexto.Text = Mid(TxtTexto.Text, 1, Len(TxtTexto.Text) - 3) & TxtMensaje.Text & "}"
           TxtTexto.TextRTF = TxtTexto.Text
           TxtMensaje.Text = ""
           TxtTexto.SelStart = Len(TxtTexto.Text)
       Else
           TxtMensaje.Text = "NO ESTAS CONECTADO"
       End If
   End If
   TxtMensaje.SetFocus
End Sub

Private Sub Command1_Click()
   Dim a As Integer
   a = MsgBox("Recibe mensajes de múltiples fuentes" & vbCrLf & "Envia mensajes a un único destinatario", vbInformation, "Que hace... DiegoWinPopUp")
End Sub

Private Sub Form_Load()
   Call CeroIndice
   Posicion = 0
   WSCRecibe(0).LocalPort = 49577
   WSCRecibe(0).Listen
   Form1.Caption = WSCEnvia.LocalIP & " - " & "Desconectado"
End Sub

Private Sub Timer1_Timer()
   If WSCEnvia.State = sckConnected Then
       Form1.Caption = WSCEnvia.LocalIP & " - " & "Conectado"
   Else
       Form1.Caption = WSCEnvia.LocalIP & " - " & "Desconectado"
   End If
End Sub

Private Sub TxtMensaje_KeyPress(KeyAscii As Integer)
   If KeyAscii = 13 Then
       Call Envio
   End If
End Sub

Private Sub WSCRecibe_ConnectionRequest(Index As Integer, ByVal requestID As Long)
   Dim cont As Integer
   Dim BanderaIndice As Boolean
   cont = 1
   BanderaIndice = False
   While BanderaIndice = False
       If Indice(cont) = False Then
           Indice(cont) = 1
           BanderaIndice = True
       Else
           cont = cont + 1
       End If
   Wend
   Load WSCRecibe(cont)
   WSCRecibe(cont).Accept requestID
   If BanderaConectado = False Then
       TxtIp.Text = WSCRecibe(0).RemoteHostIP
       Call Conexion
   End If
End Sub

Private Sub WSCRecibe_DataArrival(Index As Integer, ByVal bytesTotal As Long)
   Dim Cadena As String
   WSCRecibe(Index).GetData Cadena
   
   TxtTexto.Text = TxtTexto.TextRTF
   TxtTexto.Text = Mid(TxtTexto.Text, 1, Len(TxtTexto.Text) - 3) & vbCrLf & Cadena & "}"
   TxtTexto.TextRTF = TxtTexto.Text
   TxtTexto.SelStart = Posicion
   TxtTexto.SelLength = Len(Cadena) + 2
   TxtTexto.SelColor = &HFF5555
   Posicion = Posicion + Len(Cadena) + 2
End Sub


Editado: Favor de poner el còdigo entre las etiquetas CODE

Mensaje modificado por rob1104 el Feb 10 2008, 08:33 PM


User is offlineProfile CardPM
Go to the top of the page
+Quote Post
rob1104
post Feb 10 2008, 08:41 PM
Publicado: #2


Xbox Live... The best thing ever happened around videogames
Group Icon

Grupo: Moderadores
Mensajes: 1.623
Registrado: 7-March 05
Desde: Matamoros, Tamaulipas, Mexico
Miembro nº: 93.342



Hola, Visual Basic 6.0 utiliza la funcion Time para obtener la hora del PC, es muy sencillo de usar, por ejemplo para poner la hora en una etiqueta o en un textbox quedaria:
CODE
Label1.Caption = Time
Text1.Text = Time

Ahora, eso te funcionaria por ejemplo, para lo que necesitas de incluir la hora en el mensaje, podrias poner:
CODE
WSCEnvia.SendData TxtMensaje.Text & "(" & Time & ")"
.

Ahora, si quieres poner un reloj en tu programa, tendrias que agregar un timer con un intervalo de 1 seg. (1000 ms), y dentro del evento timer del timer, asignas Time a uan etiqueta (o donde quieras mostrar la hora), mas o menos asi:
CODE
Private Sub Form_Load()
   Timer1.Enabled = True
End Sub

Private Sub Timer1_Timer()
   Label1.Caption = Time
   Text1.Text = Time
End Sub


bye1.gif


User is offlineProfile CardPM
Go to the top of the page
+Quote Post

 
Closed TopicTopic OptionsStart new topic

Collapse

> Topicos similares

No puedo entrar al chat pinkyy 217 1 Jun 28 2008, 10:07 AM
By: Luis_Kano
Clave para tener privilegio de administrador o ... Decepcionado 633 4 Jun 26 2008, 12:37 PM
By: rioj
No puedo abrir chat de Terra manuelr223 1.328 6 Apr 28 2008, 10:37 PM
By: manuelr223
problema al querer entrar en el chat terra gonzalo_69 2.423 8 Apr 20 2008, 05:40 PM
By: Vera
chat problemas lindoboy 257 1 Mar 3 2008, 04:33 PM
By: master_slave

Google
Web www.trucoswindows.net