Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / COM / August 2008



Tip: Looking for answers? Try searching our database.

add mscomm in my activex?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Adrian Chen - 18 Jul 2008 03:32 GMT
I'am a beginner in Visual Basic 6.0. Now I try to write a ActiveX control
that is in charge of communication through COM1. So I decided to adopt
MSComm control.
   I draged a button onto the usercontrol.Then I wrote some statements in
its double-click event handler,like this:

    Private Sub Command1_Click()
    Dim MyComm As MSComm
    MyComm.CommPort = 1
    MyComm.Settings = "9600,N,8,1"
    MyComm.PortOpen = True
    End Sub

Then I started to run it in a web page by printing F5. When I double-clicked
the button, a message box jumped out on which it says as following:

Run-time error '91':
Object variable or With block variable not set

Please tell me why this happened? Where did I wrote incorrectly? Thank all
of you!

                                                                    Adrian
Chen
Nico Notter - 09 Aug 2008 16:22 GMT
Maybe like this?

>     Private Sub Command1_Click()
>     Dim MyComm As MSComm

      Set MyComm as New MSCom          

>     MyComm.CommPort = 1
>     MyComm.Settings = "9600,N,8,1"
>     MyComm.PortOpen = True

      ::::::::
     Set MyComm=Nothing

>     End Sub
KenHalter - 11 Aug 2008 21:48 GMT
>I'am a beginner in Visual Basic 6.0. Now I try to write a ActiveX control
>that is in charge of communication through COM1. So I decided to adopt
[quoted text clipped - 4 lines]
>     Private Sub Command1_Click()
>     Dim MyComm As MSComm

MSComm is a control and it needs a form. You can't create instances of it for
use "out of thin air", so you'll need to either add a form to the project and
drop the control there, or attempt to create one at runtime and force it to
"live" on an existing form.

Here's a class that wraps the Win32 APIs that deal with serial communications
that you can try, but if you want to stick with the control, you'll need a
form.

mComm Class Module
http://home.comcast.net/~hardandsoftware/CRC32.htm
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.