Hi,

I have a windows script component called vdart written in vbscript that
contains some error handling. When I write a vbscript client that
instantiates a vdart object, all works as expected. eg, errors that
vdart encounters are passed up (via err.raise) to the client script to
deal with. However, when I write a VB6 program that uses a vdart
object, an error is not passed up to the VB6 program, instead a run
time error is generated.

Any suggestions?

Regards,

Tim

Re: Problems with error handling using Windows Script Components in Visual Basic 6 by Steven

Steven
Tue Feb 22 05:37:26 CST 2005

Use an error handler......... for example;

Private Sub Command1_Click()
On Error Goto ErrHandler
'// Your code goes here
Exit Sub
ErrHandler:
If Err.Number <> 0 Then MsgBox Err.Number & " - " & Err.Description
Exit Sub
End Sub

--
Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!

"Tim" <TimJordanVBS@hotmail.com> wrote in message
news:1109071805.926794.306920@f14g2000cwb.googlegroups.com...
> Hi,
>
> I have a windows script component called vdart written in vbscript that
> contains some error handling. When I write a vbscript client that
> instantiates a vdart object, all works as expected. eg, errors that
> vdart encounters are passed up (via err.raise) to the client script to
> deal with. However, when I write a VB6 program that uses a vdart
> object, an error is not passed up to the VB6 program, instead a run
> time error is generated.
>
> Any suggestions?
>
> Regards,
>
> Tim
>



Re: Problems with error handling using Windows Script Components in Visual Basic 6 by Tim

Tim
Tue Feb 22 05:54:17 CST 2005

Steve,
My vb6 code does contain an error handler (on error resume next / on
error goto 0)... but I'm still getting a run time error from the
windows script component's err.raise.


Re: Problems with error handling using Windows Script Components in Visual Basic 6 by Steven

Steven
Tue Feb 22 06:17:49 CST 2005

Can you post the code causing the error?

--
Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!

"Tim" <TimJordanVBS@hotmail.com> wrote in message
news:1109073257.813303.262350@l41g2000cwc.googlegroups.com...
> Steve,
> My vb6 code does contain an error handler (on error resume next / on
> error goto 0)... but I'm still getting a run time error from the
> windows script component's err.raise.
>



Re: Problems with error handling using Windows Script Components in Visual Basic 6 by Tim

Tim
Tue Feb 22 08:21:26 CST 2005

Steve, I've distilled the problem I'm experiencing down to this example
:

The windows script component is comprised of 2 files:

MyTestComponent.wsc
---------------------------------
---------------------------------------------------------------
<?xml version="1.0"?>

<component>
<?component error="true" debug="false"?>

<registration
description="MyTestComponent"
progid="MyTestComponent"
version="1.00"
classid="{1566ff90-8fa0-4008-95d3-acc0aad5b79a}"
>
</registration>

<public>
<method name="CauseHavoc">
</method>
</public>

<script language="VBScript" src="MyTestComponent_Class.vbs">
<![CDATA[


Dim ThisMyTestComponent
Set ThisMyTestComponent = New MyTestComponentObj

function CauseHavoc()
ThisMyTestComponent.CauseHavoc
end function

]]>
</script>

</component>
---------------------------------------------------------------
and

MyTestComponent_Class.vbs
-------------------------------------------
---------------------------------------------------------------
Option Explicit

Class MyTestComponentObj

Public Function CauseHavoc()
MsgBox "in CauseHavoc"
Err.Raise vbObjectError+1,"MyTestComponent.
Method=CauseHavoc","Havac caused"
End Function

End Class
---------------------------------------------------------------

Now if I write a client vbs with the code below in, then, as expected,
I just see a message box of "In CauseHavoc"
However, if I put exactly the same code into a VB6 app (say a forms
load method), then I get the same message box, but then I get a run
time error from the err.raise, despite the calling code having on error
resume next / on error goto 0 around the call to the script component

ClientOfMyTestComponent.vbs
---------------------------------------------------------------
Dim MyObj
Set MyObj = CreateObject("MyTestComponent")

On Error Resume Next
MyObj.CauseHavoc
On Error Goto 0
---------------------------------------------------------------

Try it out. Weird huh.. or have I missed something!?