Her er din kode testet og det virker. Du har en Global Text variabel det er aldrig godt, deklarer altid lokalt. Winsock1.GetData Text har du flyttet til AddLW routinen. Husk også at din listview komponent skal hedde lw. (Altså Name propertien skal ændres fra default navnet: ListView1) Tag og copy/paste client og server koden til dit projekt, så burde det virke
Client kode:
Private Sub Command1_Click()
If txtUser.Text = "" Or cboPrio.Text = "" Or txtNote.Text = "" Then
MsgBox "ERROR: All field is not feld!", vbCritical
Else
Winsock1.SendData (txtUser.Text & ":" & cboPrio.Text & ":" & txtNote.Text)
End If
End Sub
Private Sub Form_Load()
Do Until Winsock1.State <> sckClosed
DoEvents
Winsock1.Close
Winsock1.Connect "194.255.58.10", 3537
Loop
End Sub
Private Sub Winsock1_Close()
Winsock1.Close
End Sub
Server kode:
Private Sub Form_Load()
Winsock1.Close
Winsock1.LocalPort = 3537
Winsock1.Listen
Call CreateView
End Sub
Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
If Winsock1.State <> sckClosed Then Winsock1.Close
Winsock1.Accept requestID
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim Text As String
Winsock1.GetData Text
AddLW Text, ":"
End Sub
Private Sub AddLW(Text As String, Delimiter As String)
Dim Item As ListItem
Dim Tmp As Variant
Dim X1 As Integer
Set Item = lw.ListItems.Add(, , Now)
Tmp = Split(Text, Delimiter)
For X1 = 0 To UBound(Tmp)
Item.SubItems(X1 + 1) = Tmp(X1)
Next X1
End Sub
Private Sub CreateView()
With lw
.LabelEdit = lvwManual
.View = lvwReport
.ColumnHeaders.Clear
.ColumnHeaders.Add , , "Time", 1500
.ColumnHeaders.Add , , "Username ", 2000
.ColumnHeaders.Add , , "Prioity ", 2000
.ColumnHeaders.Add , , "Note", 3000
End With
End Sub