1.

Solve : COM object?

Answer»

Hi
I have created a COM class in VB Script.
How can I include this class in the library, so that I can later use this class's functionality in a program written in VB Script.

please help.

thanks.If this is related to your other post and you did use the COMPONENT wizard, you should have a .WSC file.

Next step is to register your component with regsvr32 path\componentname.wsc

You can use your component in other scripts by using set object = CreateObject(progid)

progid is the name you assigned in the registration section of your component.

Hope this helps. Quote from: Sidewinder on April 13, 2008, 03:56:53 PM

Next step is to register your component with regsvr32 path\componentname.wsc


where do we write this syntax?

Thanks for help. The default location of regsvr32 is the system32 directory. You can RUN the utility from either the command prompt or the start==>run box. There is a /s switch to eliminate any message boxes.

You can GET the offical information here.




description="My Test Component"
progid="Component.TestScript"
version="1"
classid="{2154c700-9253-11d1-a3ac-0aa0044eb5f}"








Function factorial(n)
If isNumeric(n) Then
If n <= 1 Then
factorial = 1
Else
factorial = n*factorial(n-1)
End If
Else
factorial = -2 ' Error code.
End If
End Function
]]>



I copied this as a wsc file and stored it in d drive.
in cmd when i am typing regsvr32 d:\component.wsc

I am gettin the following error:

[3,2]A required attribute is missing : progid, clasid, or classid.

I don't see any thing missing?

then what's the problem?

Thanks for helping me.
There was a name property I COULD find no reference to. There were also some missing tags and a missing parameter for the factorial function.

Code: [Select]<?xml version="1.0"?>
<component>

<registration
description="My Test Component"
progid="Component.TestScript"
version="1.00"
classid="{2154c700-9253-11d1-a3ac-0aa0044eb5f}"
>
</registration>

<public>
<method name="factorial">
<PARAMETER name="n"/>
</method>
</public>

<script language="VBScript">
<![CDATA[

Function factorial(n)
If isNumeric(n) Then
If n <= 1 Then
factorial = 1
Else
factorial = n*factorial(n-1)
End If
Else
factorial = -2 ' Error code.
End If
End Function

]]>
</script>

</component>

Good luck.


Discussion

No Comment Found