narfight
Messages postés129Date d'inscriptionlundi 17 mars 2003StatutMembreDernière intervention 4 mars 2010
-
20 févr. 2008 à 12:02
narfight
Messages postés129Date d'inscriptionlundi 17 mars 2003StatutMembreDernière intervention 4 mars 2010
-
20 févr. 2008 à 13:33
Bonjour,
Je voudrais parcourir tout ma liste "LesClients" alors qu'elle est souvent modifiée (je ne peux donc pas faire un FOR normal)
Je fais donc via la fonction ForEach mais je n'arrive pas a passer l'information en ByRef pour que ma fonction "BoucleGetDataFromClients" puisse modifier les informations de ma liste.
Avez-vous une idée pour y arriver ?
Merci d'avance
<hr size="2" width="100%" /> Private Sub GetDataFromClients()
While True
LesClients.ForEach(AddressOf BoucleGetDataFromClients)
End While
End Sub
Sub BoucleGetDataFromClients(ByRef who As Client_format)
Dim readbuf As Byte() = New Byte(1024) {}
(....)
<hr size="2" width="100%" />
narfight
Messages postés129Date d'inscriptionlundi 17 mars 2003StatutMembreDernière intervention 4 mars 2010 20 févr. 2008 à 12:54
ca avance, je sais parcourir sans erreur mais je ne peux pas modifier une des variables
quand je veux faire LesClients(who).Name = DataIn(1) il me dit : "Cette expression est une valeur et ne peut donc pas être la cible d'une assignation."
je ne comprend pas ...
<hr size="2" width="100%" /> Private Sub GetDataFromClients()
While True
For who As Integer = 0 To LesClients.Count - 1
Dim readbuf As Byte() = New Byte(1024) {}
Dim DataFromClient As String = ""
Dim nbr_char As Integer
'on prend l'information
nbr_char = 0
Try
nbr_char = LesClients(who).Socket.Receive(readbuf)
DataFromClient = Encoding.ASCII.GetString(readbuf)
Catch ex As Exception
End Try
If nbr_char > 0 Then
ListBox.Invoke(dlgDisplay, LesClients(who).Name + " say : " + DataFromClient)
Dim Splitter As Regex = New Regex("\|\#\|")
Dim DataIn As String() = Splitter.Split(DataFromClient)
If DataIn(0) = "HELLO" Then
LesClients(who).Name = DataIn(1)
End If
End If
Next
End While
End Sub
<hr size="2" width="100%" />