suciwulans Active Member Licensed User Longtime User May 16, 2013 #1 I want to control PLC omron CPM1A using this command 00KSCIO 000000 and the result must @00KSCIO 0000003D*. when i use VB 6 the result is ok but when i convert to B4A the result missmatch become @00KSCIO 0000003d*. I got lower case d. any mistake conversion to B4A? can anyone help me?:sign0163: VB6 Code: Private Sub Command1_Click() txt=txtcommandPLC.text call send end sub Send: Length = Len(txt) R = Asc( "@") For I = 1 To Length K = Mid(txt , I , 1) R = R Xor Asc(k) Next txtsend.text= "@" ; Txt ; Hex(R) ; "*" ; Chr(13) B4A Code: Dim type_PLC As String dim length as string type_PLC= edtPLC.Text Length=type_PLC.Length R = Asc( "@") For I = 1 To Length K = Asc(type_PLC.CharAt(I-1)) R=Bit.Xor(R,K) Next R=Bit.ToHexString(R) edtSendPLC.Text ="@" & type_PLC & R & "*" & Chr(13)
I want to control PLC omron CPM1A using this command 00KSCIO 000000 and the result must @00KSCIO 0000003D*. when i use VB 6 the result is ok but when i convert to B4A the result missmatch become @00KSCIO 0000003d*. I got lower case d. any mistake conversion to B4A? can anyone help me?:sign0163: VB6 Code: Private Sub Command1_Click() txt=txtcommandPLC.text call send end sub Send: Length = Len(txt) R = Asc( "@") For I = 1 To Length K = Mid(txt , I , 1) R = R Xor Asc(k) Next txtsend.text= "@" ; Txt ; Hex(R) ; "*" ; Chr(13) B4A Code: Dim type_PLC As String dim length as string type_PLC= edtPLC.Text Length=type_PLC.Length R = Asc( "@") For I = 1 To Length K = Asc(type_PLC.CharAt(I-1)) R=Bit.Xor(R,K) Next R=Bit.ToHexString(R) edtSendPLC.Text ="@" & type_PLC & R & "*" & Chr(13)
stevel05 Expert Licensed User Longtime User May 16, 2013 #2 Bit.ToHexString return lowercase characters in the hexstring, you could use: Code: edtSendPLC.Text ="@" & type_PLC & R.ToUpperCase & "*" & Chr(13) Provided you have declared R as a string. Last edited: May 16, 2013 Upvote 0
Bit.ToHexString return lowercase characters in the hexstring, you could use: Code: edtSendPLC.Text ="@" & type_PLC & R.ToUpperCase & "*" & Chr(13) Provided you have declared R as a string.
suciwulans Active Member Licensed User Longtime User May 18, 2013 #3 problem solved thanks. Problem solved Upvote 0