Welcome to Dream.In.Code
Getting VB Help is Easy!

Join 136,323 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 2,766 people online right now. Registration is fast and FREE... Join Now!




mscomm

 
Reply to this topicStart new topic

mscomm, return string from modem

TrevorDawes
31 Aug, 2008 - 01:52 AM
Post #1

New D.I.C Head
*

Joined: 11 Aug, 2008
Posts: 2

Hi all, I am not sure if this has been asked before.
I want to read the string from the modem and display it in a text box (VB6).
I am stuck and would like some help on this one.
Thank you.
Trevor
User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: Mscomm
31 Aug, 2008 - 02:30 AM
Post #2

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 8,983



Thanked: 125 times
Dream Kudos: 8625
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Please post like this:

Thank you for helping us helping you.
User is online!Profile CardPM
+Quote Post

TrevorDawes
RE: Mscomm
18 Sep, 2008 - 07:43 PM
Post #3

New D.I.C Head
*

Joined: 11 Aug, 2008
Posts: 2

QUOTE(PsychoCoder @ 31 Aug, 2008 - 03:30 AM) *

Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Please post like this:

Thank you for helping us helping you.


Private Sub Command4_Click()
If Combo1.Text = "Comm 1" Then MSComm1.CommPort = 1
If Combo1.Text = "Comm 2" Then MSComm1.CommPort = 2
If Combo1.Text = "Comm 3" Then MSComm1.CommPort = 3
If Combo1.Text = "Comm 4" Then MSComm1.CommPort = 4
If Combo1.Text = "Comm 5" Then MSComm1.CommPort = 5
If Combo1.Text = "Comm 6" Then MSComm1.CommPort = 6
If Combo1.Text = "Comm 7" Then MSComm1.CommPort = 7
If Combo1.Text = "Comm 8" Then MSComm1.CommPort = 8
If Combo1.Text = "Comm 9" Then MSComm1.CommPort = 9
If Combo1.Text = "Comm 10" Then MSComm1.CommPort = 10

On Error Resume Next
With MSComm1
If .PortOpen = True Then
.PortOpen = False
Else
.PortOpen = True
If Err.Number <> 0 Then
MsgBox "Com" & .CommPort & " is not available." & vbCrLf & _
Err.Description
Err.Clear
End If
End If
End With
MSComm1.CommPort = Combo1.Text

Text3.Text = Combo1.Text


If MSComm1.PortOpen Then
Text2.Text = "Connected"
If Text2.Text = "Connected" Then Command4.Enabled = False
Text2.Text = "Connected"

End If

End Sub

On a new form I use this.
Private Sub Command1_Click()
Dim Response As Integer
For MSComm1.PortOpen = Form1.MSComm1 To MSComm1
Next
If MSComm1.PortOpen = True Then MSComm1.Output = "C"
Unload Me
Exit Sub

End Sub.
The first form works well but the next form does not send data to the comm port.

Thanking you.

Trevor
User is offlineProfile CardPM
+Quote Post

LookNAO
RE: Mscomm
19 Sep, 2008 - 12:59 PM
Post #4

D.I.C Head
**

Joined: 28 Dec, 2007
Posts: 66



Thanked: 1 times
My Contributions
QUOTE(TrevorDawes @ 18 Sep, 2008 - 08:43 PM) *

QUOTE(PsychoCoder @ 31 Aug, 2008 - 03:30 AM) *

Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Please post like this:

Thank you for helping us helping you.


Private Sub Command4_Click()
If Combo1.Text = "Comm 1" Then MSComm1.CommPort = 1
If Combo1.Text = "Comm 2" Then MSComm1.CommPort = 2
If Combo1.Text = "Comm 3" Then MSComm1.CommPort = 3
If Combo1.Text = "Comm 4" Then MSComm1.CommPort = 4
If Combo1.Text = "Comm 5" Then MSComm1.CommPort = 5
If Combo1.Text = "Comm 6" Then MSComm1.CommPort = 6
If Combo1.Text = "Comm 7" Then MSComm1.CommPort = 7
If Combo1.Text = "Comm 8" Then MSComm1.CommPort = 8
If Combo1.Text = "Comm 9" Then MSComm1.CommPort = 9
If Combo1.Text = "Comm 10" Then MSComm1.CommPort = 10

On Error Resume Next
With MSComm1
If .PortOpen = True Then
.PortOpen = False
Else
.PortOpen = True
If Err.Number <> 0 Then
MsgBox "Com" & .CommPort & " is not available." & vbCrLf & _
Err.Description
Err.Clear
End If
End If
End With
MSComm1.CommPort = Combo1.Text

Text3.Text = Combo1.Text


If MSComm1.PortOpen Then
Text2.Text = "Connected"
If Text2.Text = "Connected" Then Command4.Enabled = False
Text2.Text = "Connected"

End If

End Sub

On a new form I use this.
Private Sub Command1_Click()
Dim Response As Integer
For MSComm1.PortOpen = Form1.MSComm1 To MSComm1
Next
If MSComm1.PortOpen = True Then MSComm1.Output = "C"
Unload Me
Exit Sub

End Sub.
The first form works well but the next form does not send data to the comm port.

Thanking you.

Trevor



Trevor,
Things look good here... You have the right idea.

Don't just send the "C" and then unload... you have to wait for the data to come back in...

Also, you need to learn some of the "AT" commands for a modem:
http://www.modemhelp.net/basicatcommand.shtml

Every command you send to the modem will begin with "AT"...

Good luck

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 07:31AM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month