Jun 4, 2010 #1 P ppinky Newbie level 3 Joined Jun 4, 2010 Messages 3 Helped 0 Reputation 0 Reaction score 0 Trophy points 1,281 Location bangalore Activity points 1,299 Hi all, I am new to vb programming Can anyone help me debug the following code? Private Sub MSComm1_OnComm() Print MSComm1.Input If MSComm1.Input = A Then Print "Hello" ElseIf MSComm1.Input = B Then Print "World" End If End Sub I am getting the answer as.. B Hello But the expected answer is.. B World Thanks in advance..
Hi all, I am new to vb programming Can anyone help me debug the following code? Private Sub MSComm1_OnComm() Print MSComm1.Input If MSComm1.Input = A Then Print "Hello" ElseIf MSComm1.Input = B Then Print "World" End If End Sub I am getting the answer as.. B Hello But the expected answer is.. B World Thanks in advance..
Jun 4, 2010 #2 bassa Super Moderator Staff member Joined Jul 15, 2007 Messages 1,815 Helped 191 Reputation 402 Reaction score 156 Trophy points 1,353 Location Sri Lanka Activity points 11,237 Re: vb code debugging You may try this Code: Private Sub MSComm1_OnComm() Dim inputData as String inputData = MSComm1.Input Print inputData If inputData = "A" Then Print "Hello" ElseIf inputData = "B" Then Print "World" End If End Sub
Re: vb code debugging You may try this Code: Private Sub MSComm1_OnComm() Dim inputData as String inputData = MSComm1.Input Print inputData If inputData = "A" Then Print "Hello" ElseIf inputData = "B" Then Print "World" End If End Sub
Jun 4, 2010 #3 ama_trig Full Member level 2 Joined Oct 9, 2009 Messages 123 Helped 20 Reputation 40 Reaction score 13 Trophy points 1,298 Location Where my hard drive lives! Activity points 2,100 Re: vb code debugging also if you use bassa's way don't forget to enable comm events by setting Receive thresholds to 1.
Re: vb code debugging also if you use bassa's way don't forget to enable comm events by setting Receive thresholds to 1.
Jun 4, 2010 #4 P ppinky Newbie level 3 Joined Jun 4, 2010 Messages 3 Helped 0 Reputation 0 Reaction score 0 Trophy points 1,281 Location bangalore Activity points 1,299 Re: vb code debugging Thanks.. Your code works!! But I didn't understand why my code didn't work
Jun 4, 2010 #5 bassa Super Moderator Staff member Joined Jul 15, 2007 Messages 1,815 Helped 191 Reputation 402 Reaction score 156 Trophy points 1,353 Location Sri Lanka Activity points 11,237 vb code debugging Here some tips for that 1.Reading MSComm1.Input in first time, it gets the current buffer and clears it so you need to store it when you read it 2.Check you "IF" statement, If you compare the string value then both should be string type (Here assume your MSComm-input buffer size as 1) regards bassa
vb code debugging Here some tips for that 1.Reading MSComm1.Input in first time, it gets the current buffer and clears it so you need to store it when you read it 2.Check you "IF" statement, If you compare the string value then both should be string type (Here assume your MSComm-input buffer size as 1) regards bassa
Jun 6, 2010 #6 P ppinky Newbie level 3 Joined Jun 4, 2010 Messages 3 Helped 0 Reputation 0 Reaction score 0 Trophy points 1,281 Location bangalore Activity points 1,299 Re: vb code debugging Thanks a lot for the reply!!! I got it..