InvalidActiveXStateException

Steven McDonald

Well-known member
Joined
Jun 14, 2005
Messages
48
Location
South Africa
Programming Experience
Beginner
I'm getting an InvalidActiveXStateException. This is the code I used.
Apparently this error is thrown when the variable MSComm2 isn't instantiated properly or initialized properly.

Any Help would be gr8 :confused:


VB.NET:
[size=2][color=#0000ff]Dim[/color][/size][size=2] MSComm2 [/size][size=2][color=#0000ff]As[/color][/size][size=2] [/size][size=2][color=#0000ff]New[/color][/size][size=2] AxMSCommLib.AxMSComm

[/size][size=2][color=#0000ff]If[/color][/size][size=2] iPortNumber <> 0 [/size][size=2][color=#0000ff]Then

[/color][/size][size=2]MSComm2.Settings = "9600,n,8,1"

MSComm2.CommPort = iPortNumber

MSComm2.PortOpen = [/size][size=2][color=#0000ff]True

[/color][/size][size=2]MSComm2.RThreshold = 1

MSComm2.Refresh()

MSComm2.Output = "/read card" & Chr(10)

iAccountNum = 0

[/size][size=2][color=#0000ff]End[/color][/size][size=2] [/size][size=2][color=#0000ff]If

[/color][/size][size=2]MSComm2.Dispose()
[/size]
 
Hey Steve,

Must start here by stating that I have absolutely no idea what I'm talking about!! Not a good start perhaps, but I have seen examples where:

VB.NET:
MSComm2.CreateControl()

Is placed before any properties are set.

Sorry if this is no help what so ever!! Just something I remember from a while back, could try and find a link to the code.
 
[resolved]

Great stuff.


Thanks a million. been looking for examples for about 4-5 hours now!
It works.
 
Back
Top