Help with MSComm.Input

MSComm input IF statement

Page 1 of 1

7 Replies - 11326 Views - Last Post: 04 December 2008 - 06:47 AM Rate Topic: -----

#1 tsukukinsei  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 02-December 08

Help with MSComm.Input

Post icon  Posted 02 December 2008 - 01:09 AM

I am really new to vb programming and i was Trying to get MSComm.input to Respond to the A key when sent from another computer but it dosent seem to work :(



Private Sub MSComm1_OnComm()

If MSComm1.Input = (a) Then
	   Chat1.Text = Hello
Else
	   Chat2.Text = Chat2.Text + MSComm1.Input
	   
End If

End Sub



Is This A Good Question/Topic? 0
  • +

Replies To: Help with MSComm.Input

#2 jens  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 67
  • View blog
  • Posts: 430
  • Joined: 09-May 08

Re: Help with MSComm.Input

Posted 02 December 2008 - 11:48 AM

I think that if you change If MSComm1.Input = (a) Then
to If MSComm1.Input = "a" Then it might work.

I really don't know how MSComm works but testing for the letter a in VB is done by putting the a within citation marks.

Regards
/Jens
Was This Post Helpful? 0
  • +
  • -

#3 thava  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 180
  • View blog
  • Posts: 1,606
  • Joined: 17-April 07

Re: Help with MSComm.Input

Posted 02 December 2008 - 04:10 PM

did you get any thing in your textboxes
Was This Post Helpful? 0
  • +
  • -

#4 tsukukinsei  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 02-December 08

Re: Help with MSComm.Input

Posted 02 December 2008 - 04:37 PM

No I get nothing in Text boxes if i take the IF statement out i can get normal chat running but with the if in i get nothing the "a" doesn't seem the change anything. I Changed the code slightly and can get it to output Hello when i use a number rather than a letter but i still dont get anything from the else statement to get normal chat

This Code gives a hello when it receives a 1 but i want it to respond to characters

If MSComm1.Input = (1) Then
Chat1.Text = "Hello"
Else
Chat2.Text = Chat2.Text + MSComm1.Input
End If


Was This Post Helpful? 0
  • +
  • -

#5 thava  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 180
  • View blog
  • Posts: 1,606
  • Joined: 17-April 07

Re: Help with MSComm.Input

Posted 02 December 2008 - 04:56 PM

did you open you comm

and more over you should wait for your input

look at the following link

http://www.control.c...read/1026230716

and watch the do loop

or just use this link

http://support.microsoft.com/kb/253257
Was This Post Helpful? 0
  • +
  • -

#6 tsukukinsei  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 02-December 08

Re: Help with MSComm.Input

Posted 03 December 2008 - 01:16 AM

The Comm is open and i changed code so that i get text in text box and can transmit. the code below works the way i want it to but if i change the Chr() to anything other than 96 it dosent seem to work :(




Private Sub MSComm1_OnComm()

Com = MSComm1.Input

If Com = Chr(96) Then
End
Else
Chat2.Text = Chat2.Text + Com
End If

End Sub


Was This Post Helpful? 0
  • +
  • -

#7 jens  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 67
  • View blog
  • Posts: 430
  • Joined: 09-May 08

Re: Help with MSComm.Input

Posted 03 December 2008 - 02:20 AM

Just a thought: If you look at Com in the row Com = MSComm1.Input while running with the debugger, what does Com contain? Could it be that Com contains more than one character, e.g. "a" and vbCrLf or somthing else?
/Jens
Was This Post Helpful? 0
  • +
  • -

#8 tsukukinsei  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 02-December 08

Re: Help with MSComm.Input

Posted 04 December 2008 - 06:47 AM

Ahh I got it to work you were right turns out its transmitting a New line and carriage return every time it sends a character. Thank you guys so much :) I can now turn my lights on in my room with a Chat program :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1