Visual Basic Studio 2010: Sterling ActiveX Library - vb.net

I'm new to Visual Basic, and I've run into an error. I'm trying to write a program that will eventually be run by and in Sterling Trader (stock-trading software). I'm trying to follow the instructions of the activeX API guide for including the reference to the library. Here's what the guide says:
Create a reference to the Sterling ActiveX Library
- Select Project ---> References....from the menu
- Select Sterling 1.0 Type Library from the Available References.
- If the Sterling 1.0 Type Library is not found, select Browse and find the Sterling.tlb file.
Enable Events
- Place the following line in the general section of your code to declare the object:
Collapse | Copy Code
Dim WithEvents m_STIEvents As STIEvents
Place the following line in an initializing procedure, such as the Form_Load procedure:
Collapse | Copy Code
Set m_STIEvents = New STIEvents
Now select m_STIEvents in the Object drop down control in your code window (top left drop down control). You will see the available events in the Procedure drop down control (top right drop down control). Select the event that you would like to catch and it will be inserted into your code. It should look
something like this:
Collapse | Copy Code
Private Sub m_STIEvents_OnSTIOrderUpdateMsg(ByVal oSTIOrderUpdateMsg As
ISTIOrderUpdateMsg)
Use the oSTIOrderUpdateMsg object to gather the information from the message.
However, for some reason I was getting errors in Visual Basic 2010 (the guide must be out of date). So basically, I blindly followed Intellisense to change my code to something that I hoped would work. Here's my code:
Collapse | Copy Code
Public Class Form1
Dim WithEvents m_STIEvents As SterlingLib.STIEvents
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
m_STIEvents = New SterlingLib.STIEvents
End Sub
End Class
For now, I'm just trying to get a basic program up and running that has successfully include the library. However, when I run this, I get the following error message:
"Retrieving the COM class factory for component with CLSID {5E89F49B-6A12-420F-8570-E510EF1B580A} failed due to the following error: 80070002 The system cannot find the file specified (Exception from HRESULT: 0x80070002)"
If I click continue, the program runs and the basic window displays. I can't find anything online for how to do this at all, please help!
Thanks

I had something similar. I turned off windows UAC and the error went away
see error list
http://web.archive.org/web/20100126001718/http://blogs.msdn.com/joshpoley/pages/errors-007-facility-win32.aspx
.NET 3.5 ActiveX dll InteropServices.COMException

You have to login sterling pro for the program to work. Also install VB6 would solve the COM problem. This API is too old. Sterling is too lazy to update.

Related

Datagrid not loading the form

Here is the screenshot of it
Public Class Form3
Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'CustomerRecordsDataSet.CustomerRecords' table. You can move, or remove it, as needed.
Me.CustomerRecordsTableAdapter.Fill(Me.CustomerRecordsDataSet.CustomerRecords)
End Sub
First of all I'm just a newbie with VB. I tried searching for tuts and tried to use the datagrid. I created my MS Access document for the database and created the form so I linked the datagrid form to my main window but whenever I click the button for the datagrid form it shows InvalidOperationException was unhandled and it highlights this Me.CustomerRecordsTableAdapter.Fill(Me.CustomerRecordsDataSet.CustomerRecords).
Need an ASAP explanation thanks in-advance
The error is telling you what the problem is. The data provider isn't there (Microsoft.JET.OLEDB.4.0). This can happen if you don't have it installed, or you are running an "Any CPU" or "x64" application on a x64 system. Have you tried the ACE provider (Microsoft.ACE.OLEDB.12.0)?
Details: https://www.connectionstrings.com/access/
There are also many articles on that site that address various problems. For example: Jet for Access, Excel and Txt on 64 bit systems
The Microsoft OLE DB Provider for Jet and the Jet ODBC driver are available in 32-bit versions only. You can't run them in 64 bit mode.

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
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

Unable to Set Startup Form in Visual Studio 2012 (VB.NET)

Okay, in Visual Studio 2012 I have a VB.NET project with originally two forms. Form1 was originally set as the startup form and then obsoleted. Form2 is a nearly identical form that has all of the new desirable functionality.
In my project's settings, Form2 doesn't appear as an available option for Startup Form. (Though it is a normally-created form that inherits Form) After some "troubleshooting," Form1 has been deleted, resulting in the the "Enable Application Framework" option being disabled and no Startup Object being available. When I select anything from the Startup Object drop-down, either Sub Main or Form2, I have an error message stating either "Sub Main not found in Solution" or "Form2 is a type in Solution and cannot be used as an expression" respectively. If I try to enable "Enable Application Framework," I receive an error popup stating "Startup object must be a form when 'Enable application framework' is checked." And Application.Designer.vb is empty.
Some things I've tried:
Clean and Rebuild Solution
Restarting Visual Studio
Temporarily deleting Form1 (it's still excluded from project)
Added a new form, per Neolisk's advice. It appeared in the available objects. I selected it and turned on application framework. From here, I copied the initialization code from Form2's designer code into Form3's. All was alright. Then, I copied Form2's main code into Form3. Now, "Form3 is a type in Solution and cannot be used as an expression" appears in my error list.
With that said, my question is how can I get Visual Studio to recognize my form as a form and set Form2 as the startup object?
add InitializeComponent() in new() function in form2
Found it! The issue was an overload of the form's constructor taking a form as a parameter. Since this was the only constructor in the file, I guess it caused confusion. Commented that out and all was right with the world again.
Sometimes you have a different class name from the form file name.
Check if the class name is listed.

COM App calling .NET form calling COM form, works when compiled but not in VB6 IDE

I have a legacy VB6 / COM application that we are migrating all of the code to .NET (VB.NET) via a .NET DLL. All new form development is being done in the .NET DLL.
We use function pointers to call back to COM functions within .NET form:
I create a delegate in .NET
Set the delegate to the AddressOf the COM function at runtime (GetDelegateForFunctionPointer)
Show the .NET Form
Invoke the delegate
COM App --> .NET Form --> COM function
This works fine for functions. Where this breaks down is when I call a COM function that shows a form.
COM App --> .NET Form --> COM function --> COM Form
The COM function will execute and the form will show, but when executing in the VB6 IDE the COM form's logic does not execute. The controls are shown, but any click or form_load events are not executed. This is not an issue when the VB6 application is compiled.
Another issue I've noticed is that the VB6 IDE "freezes" until the .NET form unloads. I can not stop the debugger, set breakpoints, or interact with IDE's menu. It is as if the VB6 IDE allows the .NET DLL to take complete control over the thread. I believe these two issues are related.
EDIT:
The .NET form is modal, which may be the reason for the IDE thread lock. I'm just wondering if there is a way around it. Also, I've looked at the InteropForms Toolkit. It does not solve my problem. Even setting their sample forms to modal causes the same IDE thread lock to occur.
EDIT 2:
My previous edit did allude to another workaround: Make the .NET form show as modeless when the host application is VB6.
If InStr(Process.GetCurrentProcess().ProcessName, "vb6", CompareMethod.Text) > 0 Then
frm.Show()
Else
frm.ShowDialog()
frm.Dispose()
End If
The simple COM App --> .NET Form --> COM function --> COM Form scenario can work using the InteropForms Toolkit 2.1. Here is some code that does it, without using delegates or AddressOf.
First, we have our COM library which I'll call ComLibrary. We have the following code:
SimpleForm.frm:
Option Explicit
Private Sub Form_Load()
MsgBox "In SimpleForm_Load"
End Sub
Private Sub OkButton_Click()
Unload Me
End Sub
Private Sub TalkButton_Click()
MsgBox "Hello"
End Sub
SimpleClass.cls:
Option Explicit
Public Function ShowTheDialog() As Long
Dim f As SimpleForm
Set f = New SimpleForm
f.Show vbModal
ShowTheDialog = 1
End Function
Compile this to a .dll so that we can reference it in our .NET library.
Next, we'll create our .NET forms library. I did this using the "VB6 InteropForms Library" project template using the default project name of InteropFormsLibrary1. I added a reference to the ComLibrary project. The form has a single button named "CallComFunction."
InteropForm1.vb:
Imports Microsoft.InteropFormTools
<InteropForm()> _
Public Class InteropForm1
Private Sub CallComFunction_Click(sender As System.Object, e As System.EventArgs) Handles CallComFunction.Click
Dim sc As ComLibrary.SimpleClass
sc = New ComLibrary.SimpleClass
Dim result As Integer
result = sc.ShowTheDialog()
End Sub
End Class
Before compiling this, we need to create the InteropForms wrapper classes per the toolkit documentation. Do this by accessing the Tools > Generator InteropForms Wrapper Classes menu.
Finally, we create the VB6 host app.
Form1.frm:
Option Explicit
Private Sub DialogButton_Click()
Dim f As InteropFormLibrary1.InteropForm1
Set f = New InteropForm1
f.Show vbModal
End Sub
When I run the host application in the VB6 IDE, I can click the button the VB6 form which then displays the VB.NET form. From there, I click another button which uses an instance of SimpleClass to display SimpleForm. The MsgBox statements in the form load event and the button click handlers work. And everything works when compiling the VB6 host app as well.
It looks like your VB6 IDE is loading your VB application as an "in-process" COM object, although that does not make much sense to me... However if that is the case,it would mean that you have a single message loop for your application and your debugger, which might explain at least some of these issues. I have not used a VB-classic IDE in too many years, so I do not know how it works. Maybe there is an option there somewhere to load your app in a separated process?
Update -
It seems my guess was correct. See this other question and its answers for more information and possible workarounds:
https://stackoverflow.com/a/518217/501196

VB.NET 2005 problems with Designer not being able to process a code line

I have a problem in my project with the .designer which as everyone know is autogenerated and I ahvent changed at all. One day I was working fine, I did a back up and next day boom! the project suddenly stops working and sends a message that the designer cant procees a code line... and due to this I get more errores (2 in my case), I even had a back up from the day it was working and is useless too, I get the same error, I tryed in my laptop and the same problem comes. How can I delete the "FitTrack"? The incredible part is that while I was trying on the laptop the errors on the desktop were gone in front of my eyes, one and one second later the other one (but still have the warning from the designer and cant see the form), I closed and open it again and again I have the errors...
The error is:
Warning 1 The designer cannot process the code at line 27:
Me.CrystalReportViewer1.ReportSource = Me.CrystalReport11
The code within the method 'InitializeComponent' is generated by the designer and should not be manually modified. Please remove any changes and try opening the designer again. C:\Documents and Settings\Alan Cardero\Desktop\Reportes Liquidacion\Reportes Liquidacion\Reportes Liquidacion\Form1.Designer.vb 28 0
I would back up the designer.cs file associated with it (like copy it to the desktop), then edit the designer.cs file and remove the offending lines (keeping track of what they do) and then I'd try to redo those lines via the design mode of that form.
I would take out the static assignment in the designer to the resource CrystalReport11 and then add a load handler to your form and before setting the ReportSource back to CrystalReport11 do a check
If(Not DesignMode) Then Me.CrystalReportViewer1.ReportSource = Me.CrystalReport11
Here is a mockup..
Public Sub New()
InitializeComponent()
AddHandler Me.Load, New EventHandler(AddressOf Form1_Load)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
If (Not DesignMode) Then Me.CrystalReportViewer1.ReportSource = Me.CrystalReport11
End Sub
You should be able to take a backup, clear the lines that are having problems then when you re-open it the designer will fix the code.
The key is that you want to let the designer re-generate, then just validate that all needed lines are there.
That usually works for me, but you just have to be sure to remove all lines that it doesn't like.
I do an easy way; Right Click on the report then choose Run Custom Tool.
Automatically it fixes all problems and working for me, i solve 52 crystal ReportViewer errors.