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