Cannot create active x component error
Hi,
I am using visual basic.net to move some linear stages through a serial port. I managed to write a code which worked and I was able to move the stages etc. However the computer I want to use does not have a serial port and so I am now using a serial to USB adapter. When I now try to run the program I get an error message saying:
An unhandled exception of type 'System.Exception' occurred in microsoft.visualbasic.dll
Additional information: Cannot create ActiveX component.
when I click on the "Open com port" button.
The start of my piece of code is:
Dim OldHandshake As Integer
Dim Oldsettings As String
Dim OldMode As Integer
Dim OldInputLen As Integer
Dim myCom As Object
Private Sub OpenComPortRenumber_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenComPortRenumber.Click
myCom = CreateObject("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 = 0
.Settings = "9600,N,8,1"
.InputMode = MSCommLib.InputModeConstants.comInputModeText
.InputLen = 1
.RThreshold = 1
MsgBox("Opening Com Port")
System.Threading.Thread.CurrentThread.Sleep(1000)
MsgBox("Done")
MsgBox("Renumbering Units")
.output = Chr(0) + Chr(2) + Chr(0) + Chr(0) + Chr(0) + Chr(0) 'renumber the units
MsgBox("Done")
End With
End Sub
The code cannot run past the myCom = CreateObject("MSCommLib.MSComm") line of code.
I would appreciate any help as I am very new to all of this.
Louise
|