Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Help me debug my VB program

Status
Not open for further replies.

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..
 

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

also if you use bassa's way don't forget to enable comm events by setting Receive thresholds to 1.
 

Re: vb code debugging

Thanks.. Your code works!! But I didn't understand why my code didn't work
 

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
 

Re: vb code debugging

Thanks a lot for the reply!!! I got it..
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top