bonjour , je cherche a envoyé une trame sous access sur un port rs232 mais l envoie ne marche si vous pouviez maider svp mon code est le suivant : (ici je cherche a convertir en ascii des txtbox qui sont le resultat d une requete mais c est surtout l envoi de "res" qui me pose probleme )
private sub envoie_click() Dim res As String Dim N As String Dim T As String Dim u As Integer Dim bd As Database Dim matable As Recordset
N = Asc(nbpages) N = N & 112 T = 84 & Asc(tps_en_sec) & 115
Set bd = CurrentDb Set matable = bd.OpenRecordset("requête1" ) matable.MoveFirst
x = Forms!choixafichage!Modifiable55 Do While Not matable.EOF If matable!numafichages = x Then
res = res & 167 & TextASCII(txt1) & 167167 & 167 & TextASCII(txt2) & 167167 & 167 & TextASCII(txt3) & 167167 & 167 & TextASCII(txt4) & 167167 & T
End If
matable.MoveNext Loop matable.Close
res = N & res
MSComm0.output = res End Sub
Private Function TextASCII(Text As String, Optional Maxlen As Integer = 24) As String Dim LenT As Integer, Sa As Integer, Se As Integer, Retour As String, i As Integer LenT = Len(Text) Sa = (Maxlen - LenT) / 2 Se = Maxlen - LenT - Sa If Text <> " " Then Text = Space(Sa) & Text & Space(Se) For i = 1 To Maxlen Retour = Retour & Asc(Mid(Text, i, 1)) Next Else For i = 1 To Maxlen Retour = Retour & Asc(" " ) Next End If TextASCII = Retour End Function
Private Sub MSComm0_Enter() MSComm0.comport = 2 MSComm0.setting = "9600,n,8,1" MSComm0.PortOpen = True End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer) MSComm0.PortOpen = False End Sub
si vous pouviez m aider pour envoyer cette trame je vous remercie @ bientot
Marsh Posté le 08-06-2005 à 12:06:39
bonjour , je cherche a envoyé une trame sous access sur un port rs232 mais l envoie ne marche si vous pouviez maider svp
mon code est le suivant :
(ici je cherche a convertir en ascii des txtbox qui sont le resultat d une requete mais c est surtout l envoi de "res" qui me pose probleme )
private sub envoie_click()
Dim res As String
Dim N As String
Dim T As String
Dim u As Integer
Dim bd As Database
Dim matable As Recordset
N = Asc(nbpages)
N = N & 112
T = 84 & Asc(tps_en_sec) & 115
Set bd = CurrentDb
Set matable = bd.OpenRecordset("requête1" )
matable.MoveFirst
x = Forms!choixafichage!Modifiable55
Do While Not matable.EOF
If matable!numafichages = x Then
res = res & 167 & TextASCII(txt1) & 167167 & 167 & TextASCII(txt2) & 167167 & 167 & TextASCII(txt3) & 167167 & 167 & TextASCII(txt4) & 167167 & T
End If
matable.MoveNext
Loop
matable.Close
res = N & res
MSComm0.output = res
End Sub
Private Function TextASCII(Text As String, Optional Maxlen As Integer = 24) As String
Dim LenT As Integer, Sa As Integer, Se As Integer, Retour As String, i As Integer
LenT = Len(Text)
Sa = (Maxlen - LenT) / 2
Se = Maxlen - LenT - Sa
If Text <> " " Then
Text = Space(Sa) & Text & Space(Se)
For i = 1 To Maxlen
Retour = Retour & Asc(Mid(Text, i, 1))
Next
Else
For i = 1 To Maxlen
Retour = Retour & Asc(" " )
Next
End If
TextASCII = Retour
End Function
Private Sub MSComm0_Enter()
MSComm0.comport = 2
MSComm0.setting = "9600,n,8,1"
MSComm0.PortOpen = True
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
MSComm0.PortOpen = False
End Sub
si vous pouviez m aider pour envoyer cette trame je vous remercie @ bientot