Search code examples
vb.netstimulsoft

stimulsoft report add my function with vb.net


we can add our function with this way https://www.youtube.com/watch?v=TEYuQmia9IY

but it in c# i want the way in vb.net

the problem in using namspacing in vb.net

thanks


Solution

  • In the video posted there are some critical steps missing. It seems that they are given for granted but without it you could not achieve a successful reference to your code from the Report Designer.

    First: To clarify the problem between VB.NET and C#. If you want to use VB as scripting language for your report you need to set it in the Report Properties. You will find the ScriptLanguage property in the same property grid for the report where they set the reference to your application. Changing this property is not required because this property refers to the code written inside the report not the code in which you have written your app.

    Second: In your VB.NET app your code that defines the function should be as this

    Namespace MyFunc
        Public Class Main
            Public Shared Sub ShowMessage(text As String)
                MessageBox.Show(text)
            End Sub
        End Class
    End Namespace
    

    Usually in VB.NET you don't define explicitily a namespace (everything is inside the main namespace defined in the project properties) but if you want a separate namespace there is nothing to stop you.

    Third: In the Report Code Page you write

    Imports WindowsFormApplication2.MyFunc
    

    Fourth: After completing the design of your report remember to save it in the same folder where the application is created. (Usually Project\BIN\DEBUG) Otherwise the reference to your executable will fail.

    Fifth: The Stimulsoft assemblies are installed in the GAC, but to be sure that they are found when you run the report don't forget to set their references to Copy Local = True when you run your app inside Visual Studio