|
-
October 28th, 1999, 04:02 PM
#1
MSComm run-time error
Hello there. I'm trying to use my COM1 port to send/receive messages through my modem. I think the problem may be that I'm not declaring the MSComm control properly. Whenever I run the code, I get an error saying "Object variable with block variable not set." I have no idea what that means, so if you could please help me, I'd be very grateful. Here's the first part of the code:
Option Explicit
Dim mscomm1 As Control 'Is that right?
Dim InBuff As String
Private Sub Form_Load()
' Use COM1.
mscomm1.CommPort = 1 'the debugger goes to this line first
' 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
Text1.Text = "ping www.altavista.com"
End Sub
Many, many thanks in advance!
-
October 29th, 1999, 12:43 AM
#2
Re: MSComm run-time error
First of all, Did you add the control to the project, From Project->Controls?
If yes, then did you create one on the Form?
If yes, then
1. You dont need to declare
DIm Mscomm1 as contrl .
2. Even if you Decalre, before accessing its properties, specially for Controls, you need to set them to an existing instance of the control. Like
set mscomm1 = Me.MsCom2 ' or what ever
3. VB 6.0 allows controls to be created Runtime with
Me.Comtrols.Add method. Please check on that to know how to add a MsComm control runtime, and then set your reference to it.
"With Block not set" means the variable ' control/class is not initialised to any proper value.
RK
-
October 29th, 1999, 11:52 AM
#3
Re: MSComm run-time error
Ravi- thank you very much for your help here. I've spent many hours trying to track down this very information. Most people don't know how to do this and most books don't even begin to cover it. It's a blessing to find someone willing to share their knowledge. I was in class until pretty late last night and I'm just now finding time to research the infromation you sent me.
Thanks again!
-Matthew
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|