Link to home
Start Free TrialLog in
Avatar of axnst2
axnst2Flag for United States of America

asked on

"Object variable or With block variable not set"

I am trying to call a simple class module sub with a command button.  When I do that I get the error.  However, it compiles fine.

Here is the code from the form:

Private Sub Connect_Click()
Dim myLaser As CLaser
myLaser.Connect
End Sub

Here is the code from the class:

Public Sub Connect()
Dim Number As String

Number = GetLaserServerIP
FLaserTestApp.Text1.Text = SetIP(Number)
End Sub

I think my problem is really the way I call the connect function from the form.  I am not sure what's wrong.  Please help me.

Thanks,
axnst2
Avatar of bkthompson2112
bkthompson2112

Hi axnst2,

try changing to this:

Private Sub Connect_Click()
Dim myLaser As New CLaser    '''' MODIFIED
myLaser.Connect
End Sub

bkt
ASKER CERTIFIED SOLUTION
Avatar of bkthompson2112
bkthompson2112

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Glad I could help.

Thanks for the 'A' :)