Problem with Eviews COM Automation

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

bigmonty
Posts: 7
Joined: Tue Jan 29, 2013 10:12 pm

Problem with Eviews COM Automation

Postby bigmonty » Wed May 15, 2013 1:56 am

I was experimenting with Eviews COM Automation tool. I wrote the following code in VB.NET to call a Eviews workfile from VB.

Code: Select all

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click Dim mgr As New EViews.Manager Dim app As EViews.Application app = mgr.GetApplication(EViews.CreateType.NewInstance) app.Run("wfopen J:\Hans\MOF\EViewsStuff\macmod.wf1") End Sub
After I run the code I get a form with a button. I click the button but nothing happens. I understand that I have to find a way to display the object but not sure
how to do that. Any help would be highly appreciated.

EViews Steve
EViews Developer
Posts: 844
Joined: Tue Sep 16, 2008 3:00 pm
Location: Irvine, CA

Re: Problem with Eviews COM Automation

Postby EViews Steve » Fri May 17, 2013 2:32 pm

That's actually a feature. A lot of COM users would prefer that the application they're controlling does NOT show up on the user's desktop because they only want to use it as a resource for their own application.

In any case, the answer you're looking for is:

Code: Select all

app.Show()
This will make the application appear. This does mean that when you are done with EViews and your program quits, EViews will hang around until someone manually closes it. Only hidden instances of EViews will automatically quit when their COM client is finished with it.

You can call:

Code: Select all

app.Hide()
to re-hide the application.

Steve

bigmonty
Posts: 7
Joined: Tue Jan 29, 2013 10:12 pm

Re: Problem with Eviews COM Automation

Postby bigmonty » Sat May 18, 2013 9:17 pm

Thanks a lot Steve for your answer. I have another question for you if you don't mind.

Code: Select all

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click Dim myVar myVar = TextBox1.Text Dim mgr As New EViews.Manager Dim app As EViews.Application app = mgr.GetApplication(EViews.CreateType.NewInstance) app.Run("wfopen J:\Rushad\MOF\macmodr2.wf1") app.Run("show myVar") app.Show() End Sub
In the above VB.net code, I want the user to enter the name of the variable in the TextBox1 which is saved as myVar and then I want to display myVar in
the subsequent app.Run("show myVar") command. But the problem is myVar is not recognized by the instruction passed on to Eviews. How to get around that
problem?

EViews Steve
EViews Developer
Posts: 844
Joined: Tue Sep 16, 2008 3:00 pm
Location: Irvine, CA

Re: Problem with Eviews COM Automation

Postby EViews Steve » Sun May 19, 2013 4:37 pm

If you use the code:

Code: Select all

app.Run("show myVar")
that command is just like typing in the string "show myVar" inside the EViews command window. Assuming your workfile doesn't have an object named "myVar", EViews wouldn't know what to do with that command.

What you meant to do is use the value of myVar instead of the literal string "myVar" in your run command. This means you have to build a string that starts with "show " and then ends with the value of myVar. To do that in VB.NET, you would do this:

Code: Select all

app.Run("show " & myVar)
Steve


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests