Author Topic: ActiveX with VB.NET  (Read 29795 times)

Support

  • Administrator
  • *****
  • Posts: 22
    • View Profile
ActiveX with VB.NET
« on: June 22, 2014, 12:57:23 AM »
I was curious if Visual BASIC .NET could create controls Dave could use with his Script BASIC COM extension module. From my initial research, it looks like it can.

Create ActiveX in .NET Step by Step

How to generate an OCX activex control using VB.NET


dzzie

  • Guest
Re: ActiveX with VB.NET
« Reply #1 on: June 22, 2014, 02:52:35 PM »
yup should work without a problem, I have used .NET code from VB6 projects through COM before. You just have to set the COM aware attribute to true
and then register the typelib or generate a registry file to include on  distribution.

Support

  • Administrator
  • *****
  • Posts: 22
    • View Profile
Re: ActiveX with VB.NET
« Reply #2 on: June 22, 2014, 06:15:02 PM »
That's great news Dave. I'm assuming this holds true for visual COM controls. (ribbon control, ...)

The Date Picker control might be a good first one to try. You already nailed the VB ActiveX version.



I attached the project and the compiled .exe for this.
« Last Edit: June 22, 2014, 10:01:05 PM by support »

dzzie

  • Guest
Re: ActiveX with VB.NET
« Reply #3 on: June 23, 2014, 11:03:22 AM »
attached, see readme

Support

  • Administrator
  • *****
  • Posts: 22
    • View Profile
Re: ActiveX with VB.NET
« Reply #4 on: June 23, 2014, 12:36:48 PM »
Amazing!



Code: [Select]
import com.inc

cs = CreateObject("Sample.Sample")

if cs = 0 then
print "Failed to create the C# com object did you register the dll with regasm and have .NET installed?"
return
end if

d = CallByName(cs, "GetDate")
print "User Selected date: ", d

C:\SB22\sbcom\sbvb6>scriba cs_date.sb
User Selected date: 6/23/2014
C:\SB22\sbcom\sbvb6>


Q. What does the return do in your example?
« Last Edit: June 23, 2014, 02:04:05 PM by support »

dzzie

  • Guest
Re: ActiveX with VB.NET
« Reply #5 on: June 23, 2014, 02:29:19 PM »
the return just exits the script early so I didnt have to protect the lower block with an else end if
Wasnt sure if it would work but it did. swap the equal to not equal logic to test

Support

  • Administrator
  • *****
  • Posts: 22
    • View Profile
Re: ActiveX with VB.NET
« Reply #6 on: June 23, 2014, 03:44:30 PM »
Didn't know that and have always used END. Thanks for the trick.


Support

  • Administrator
  • *****
  • Posts: 22
    • View Profile
Re: ActiveX with VB.NET
« Reply #7 on: June 23, 2014, 11:28:26 PM »
I was unable to get the .net date picker to run under Windows 7.  I registered the control and copied the Sample.dll to the bin directory.


C:\sb22_32\sbvb-2>scriba cs_date.sb
Failed to create the C# com object did you register the dll with regasm and have .NET installed?(0): error &H26:The command RETURN can not be executed, because there is no where to return.

I think the RETURN is causing scriba to exit due to failure and END should probably be used. I'm surprised your not seeing an ERROR 38 with the RETURN with nowhere to go. (possibly exited before error message could be displayed ?)

FYI: You can add your own key/data pairs to the Script BASIC configuration file and call it with the SB ext. module API.

BTW: I really enjoy your videos. Very informative!
« Last Edit: June 24, 2014, 12:00:05 AM by support »

dzzie

  • Guest
Re: ActiveX with VB.NET
« Reply #8 on: June 24, 2014, 06:28:59 AM »
I just tested it on a Win7 machine, the registry file method wasnt enough not sure why.

For win7 i had to fall back to the regasm [dll path] method in which case it then worked as expected.

Your right on the return thing, oops, guess I wasnt reading the output close enough. End is what I was looking for thanks :)

Support

  • Administrator
  • *****
  • Posts: 22
    • View Profile
Re: ActiveX with VB.NET
« Reply #9 on: June 25, 2014, 12:23:21 AM »
The RegAsm of the DLL did the trick on Windows 7 64 bit.



C:\sb22_32\sbvb-2>C:\Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe Sample.dll
Microsoft .NET Framework Assembly Registration Utility version 4.0.30319.18408
for Microsoft .NET Framework version 4.0.30319.18408
Copyright (C) Microsoft Corporation.  All rights reserved.

Types registered successfully

C:\sb22_32\sbvb-2>scriba cs_date.sb
User Selected date: 6/25/2014
C:\sb22_32\sbvb-2>