|
-
Jun 18th, 2007, 08:59 AM
#1
Thread Starter
New Member
MSComm woes
Hi,
I'm trying to write some code to open a serial port and send data to a motorised x-y stage.
i'm trying to do this in a language called ADL (specific to varian scientific instruments) which is based on Sax Basic, which is VB compatible.
I have referenced the MSCommLib .ocx and am using the following code to open the port ready for various bits of data to be sent
Code:
Dim OldHandShake As Integer
Dim OldSettings As String
Dim OldMode As Integer
Dim OldInputLen As Integer
Sub PortControl
Dim myCom As MSCommLib.MSComm
With myCom
.CommPort = 1
.PortOpen = True
'save current port settings
OldHandShake = .Handshaking
OldSettings = .Settings
OldMode = .InputMode
OldInputLen = .InputLen
'set the new settings
.Handshaking = comNone
.Settings = "9600,N,8,1"
.InputMode = comInputModeText
.InputLen = 1
.RThreshold = 1
End With
End Sub
Sub Main
PortControl
End Sub
when i run the script i get the following error
Error in file C:\Documents...etc..... at line 15 position 0 (10094) ActiveX Automation: Object var is "Nothing". ......
and it highlights the line .CommPort = 1
Sadly im unsure what this actually means. I'm a chemist, not a programmer, thats been thrown in the deepend without a float. I'm learning fast but this has me a bit a stumped.
Any help would be greatly appreciated. Thanks
EDIT: i should also mention that this script has no form/frontend, it is a macro that runs within the Varian Software
Last edited by renzokuken; Jun 18th, 2007 at 09:05 AM.
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
|