Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1332 connectés 

  FORUM HardWare.fr
  Programmation
  VB/VBA/VBS

  Envoie d'une variable avec SendData --- Besoin d'aide :(

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

Envoie d'une variable avec SendData --- Besoin d'aide :(

n°235647
william10
Posté le 27-10-2002 à 20:30:58  profilanswer
 

alors voilà, lors du click sur un bouton un texte est envoyé sur un pc en réseau local connecté grace a winsock ou tourne le meme programme. Voici le code lors du clik sur un bouton :
 
Private Sub Command3_Click()
WS.SendData (Text2)
Text2.Text = ""
End Sub
 
l'autre pc recoit le texte grace au code suivant:
 
Private Sub WS_DataArrival(ByVal bytesTotal As Long)
WS.GetData Data
Text1.Text = Data
end sub
 
tout cela marche.
LE problème vient du fait que maintenant j'aimerai envoyer a l'autre pc le nombre que contient une variable que l'on va appeller x lorsque je clique sur un autre bouton:
 
moi j'écris:
 
Private Sub Command5_Click()
WS.SendData (x)
End Sub
 
et sur l'autre pc:  
 
Private Sub WS_DataArrival(ByVal bytesTotal As Long)
WS.GetData x
Text2.Text = x
end sub
 
Et là ça ne marche pas
Si dans le dataarrival je met data à la place des x, il le confond avec les data précédent, donc je ne sais pas comment faire :(
 
plese help :)
 

mood
Publicité
Posté le 27-10-2002 à 20:30:58  profilanswer
 

n°235661
drasche
Posté le 27-10-2002 à 21:49:38  profilanswer
 

n'est-ce pas là un problème de protocole que tu dois établir?  Je veux dire, ton programme en réception sait-il à l'avance ce qu'il va recevoir comme donnée?


---------------
Whichever format the fan may want to listen is fine with us – vinyl, wax cylinders, shellac, 8-track, iPod, cloud storage, cranial implants – just as long as it’s loud and rockin' (Billy Gibbons, ZZ Top)
n°235985
william10
Posté le 28-10-2002 à 16:07:25  profilanswer
 

en gros la commande senddata envoie la valeur d'une variable :
 
ex :  winsock.senddata (variable)
 
(dites moi si j'ai faux :)
 
et la commande getdata recoit ces données
si l'on introduite getdata dans une sub dataarrival, des qu'un senddata est détécté getdata recoit les donnée :
 
ex:  
 
winsowk.getdata data
 
 
--------------------
 
ma question est peut-ton envoyer plusiseurs choses en meme temps et comment les differencier à l'arrivée ????
 
merci d'avance

n°236015
drasche
Posté le 28-10-2002 à 16:31:05  profilanswer
 

tu peux envoyer qu'une variable à la fois, genre une string.  Une string peut-être issue de la conversion d'un tableau par exemple.
 
C'est clair que c'est à toi de décider la façon dont tu vas faire passer tes données de l'un à l'autre.  Et pour cela, tu dois décider d'un protocole.  Genre le premier caractère identifie le type de donnée, et le second la longueur, etc etc...
 
J'ai utilisé cela dans le passé et je faisais des strings à ma sauce que j'envoyais d'un coup.  Au niveau DataArrival, fallait bien sûr que la fonction sache interpréter les données reçues.  Ici, c'est à ton imagination de jouer.


---------------
Whichever format the fan may want to listen is fine with us – vinyl, wax cylinders, shellac, 8-track, iPod, cloud storage, cranial implants – just as long as it’s loud and rockin' (Billy Gibbons, ZZ Top)
n°236022
william10
Posté le 28-10-2002 à 16:39:16  profilanswer
 

ok merci, je vois en gros ce que tu veux dire, et j'ai une petite idée de ce que je vais faire :)
 
@ +

n°236289
william10
Posté le 28-10-2002 à 23:25:56  profilanswer
 

en fouinant un peu des sources j'ai trouvé ça :
 
socket.GetData donnee
     If InStr(1, donnee, "PERDU", vbBinaryCompare) Then
         donnee = Replace(donnee, "PERDU", "", 1, , vbBinaryCompare)
         decoup = Mid(donnee, InStr(1, donnee, "pion:", vbBinaryCompare) + 5)
         pos = InStr(1, decoup, "|", vbBinaryCompare)
         donnee = Mid(decoup, 1, pos - 1)
         decoup = Mid(decoup, pos + 1)
 
estce que kelkun pourrait me dire clairemetn ce que ça veut dire ?
particulièrement le  
-Instr et a koi corresponds ce kil y a entre()
-le Mid et a koi corresponds ce kil y a entre()
 
j'ai vu ça ds plusieurs source. Ne cerait-il pas un moyen de séparere et de récupérer au bon endrois les donnes reçus par senddata ???

n°236290
Harkonnen
Modérateur
Un modo pour les bannir tous
Posté le 28-10-2002 à 23:28:58  profilanswer
 

Citation :


 
Visual Basic for Applications Reference
 
InStr Function
       
 
Returns a Variant (Long) specifying the position of the first occurrence of one string within another.
 
Syntax
 
InStr([start, ]string1, string2[, compare])
 
The InStr function syntax has these arguments:
 
Part Description  
start Optional. Numeric expression that sets the starting position for each search. If omitted, search begins at the first character position. If start contains Null, an error occurs. The start argument is required if compare is specified.  
string1 Required. String expression being searched.  
string2 Required. String expression sought.  
compare Optional. Specifies the type of string comparison. If compare is Null, an error occurs. If compare is omitted, the Option Compare setting determines the type of comparison. Specify a valid LCID (LocaleID) to use locale-specific rules in the comparison.  
 
 
Settings
 
The compare argument settings are:
 
Constant Value Description  
vbUseCompareOption -1 Performs a comparison using the setting of the Option Compare statement.  
vbBinaryCompare 0 Performs a binary comparison.  
vbTextCompare 1 Performs a textual comparison.  
vbDatabaseCompare 2 Microsoft Access only. Performs a comparison based on information in your database.  
 
 
Return Values
 
If InStr returns  
string1 is zero-length 0  
string1 is Null Null  
string2 is zero-length start  
string2 is Null Null  
string2 is not found 0  
string2 is found within string1  Position at which match is found  
start > string2 0  
 
 
Remarks
 
The InStrB function is used with byte data contained in a string. Instead of returning the character position of the first occurrence of one string within another, InStrB returns the byte position.
 
 
--------------------------------------------------------------------------------
Send feedback to MSDN.Look here for MSDN Online resources.


 

Citation :


 
Visual Basic for Applications Reference
 
Mid Function
       
 
Returns a Variant (String) containing a specified number of characters from a string.
 
Syntax
 
Mid(string, start[, length])
 
The Mid function syntax has these named arguments:
 
Part Description  
string Required. String expression from which characters are returned. If string contains Null, Null is returned.  
start Required; Long. Character position in string at which the part to be taken begins. If start is greater than the number of characters in string, Mid returns a zero-length string ("" ).  
length Optional; Variant (Long). Number of characters to return. If omitted or if there are fewer than length characters in the text (including the character at start), all characters from the start position to the end of the string are returned.  
 
 
Remarks
 
To determine the number of characters in string, use the Len function.
 
Note   Use the MidB function with byte data contained in a string, as in double-byte character set languages. Instead of specifying the number of characters, the arguments specify numbers of bytes. For sample code that uses MidB, see the second example in the example topic.
 
 
--------------------------------------------------------------------------------
Send feedback to MSDN.Look here for MSDN Online resources.


---------------
J'ai un string dans l'array (Paris Hilton)

Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  VB/VBA/VBS

  Envoie d'une variable avec SendData --- Besoin d'aide :(

 

Sujets relatifs
Besoin d'aide pour un javascript svpDiv et variable, placer un div en fonction d'une variable ??
prbleme avec les caracteres français lors de l'envoie du formulaire!!regex, besoin de confirmation ;-)
Aide pour une débutante en prog .NET[DEBUTANT EN PROGRA] besoin d'aide avec borland builder c++ 6.0
Aide sur une Requete SQL[PHP] Besoin d'aide pour simplifier ma requête...
Plus de sujets relatifs à : Envoie d'une variable avec SendData --- Besoin d'aide :(


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR