04-07-2010, 09:18 PM
Sorry you can't do it that way. You can create Classes in VBS then call the class.function, but they do not compile into DLLs. You need to use Visual Studio 6 or .NET to create dlls then install them as COM components in order to consume them in VBS/QTP. VS.NET does it pretty easily by selecting "Make Assembly COM visible" then registering. There are plenty of Google examples how to do this. You can even use the free Express editions of Visual studio to create and compile the dll files.
Easiest thing to do for QTP is create a VBS file then associate the file with your test/action in settings. You can still use classes.
If you still wish to use DLLs then here is how. Create/compile dll using Visual studio. Register as COM component (Resasm.exe, I think...it's part of .NET utilities). Now QTP:
I hope this helps.
Easiest thing to do for QTP is create a VBS file then associate the file with your test/action in settings. You can still use classes.
Code:
'create class
Class TestMe
public sub HelloWorld()
msgbox "Hello there"
end sub
End Class
'instantiate and consume
dim cltest: set cltest = New TestMe
cltest.HelloWorld
If you still wish to use DLLs then here is how. Create/compile dll using Visual studio. Register as COM component (Resasm.exe, I think...it's part of .NET utilities). Now QTP:
Code:
'if you use a namespace, don't forget to include it namspace.class
dim cltest:set cltest = CreateObject("cltestdll")
cltest.HelloWorld
I hope this helps.