Click to See Complete Forum and Search --> : How do I load mscomm1?


SocketMonkey
November 5th, 1999, 03:47 PM
The goal here is to access my serial port COM1 so that I can ping through my modem. I've come to understand that I need to use the mscomm control to accomplish this. Whenever I try to run the code I get the following message:
"Run time error '91': Object variable with Block varialble not set"
I have (correctly?) added the control to my form by going to Project -> Add User Controls and selecting something like "Microsoft Communications Control."
Other than setting the control's name to "mscomm1", I have not modified the properties of the control outside of trying to do it from the Form_Load Sub. I've had a couple of courses in VB but other than that, I'm a total newbie. Could someone please spell out the solution for me as simply as possible? I will be extremely grateful and you will have good karma! Here's a part of my code:
Option Explicit
Dim mscomm1 As Control 'work around this
Dim InBuff As String
Dim sIPAddress As String
Dim sReturnMsg As String

Private Sub Form_Load()

'Load mscomm1 'this didn't help
'Me.mscomm1 = Commport 'this didn't help either
' Use COM1
mscomm1.Commport = 1 'the debugger goes straight to this line
' 9600 baud, no parity, 8 data, and 1 stop bit.
mscomm1.Settings = "9600,N,8,1"
' Tell the control (MSComm1) to read entire buffer when Input
' is used.
mscomm1.InputLen = 0
' Open the port.
mscomm1.PortOpen = True

End Sub

November 5th, 1999, 06:41 PM
Just an idea. If you've placed the control on the form, you don't have to Dim a variable with that name. The control name is implicit in the procedure.

bertovic@pimco.com

SocketMonkey
November 5th, 1999, 06:56 PM
Perhaps I haven't placed the control "on the form." If I take away the line where I Dim mscomm1 As Control, I get a "variable not defined error." This makes me think that the form isn't seeing the control at all. Does that sound right? If someone could please tell me how to place a control on a form, I'd be mighty grateful. Please spell it out for me in the simplest terms possible. Many thanks!
-Matt

November 12th, 1999, 05:55 PM
Go to the components tab and select MS Communications (if you haven't already done that). On the toolbox, there will appear a symbol like a phone. This is the MSComm symbol. Double-click on it (while a form is opened) and it will place this control on your form. You can then right click on the MSComm1 control and select properties. You can then set the com port, parity, etc. to the settings you need.

SocketMonkey
November 13th, 1999, 12:01 AM
Thank you very much! I'll look into your advice.