Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can a form created in Visual Basic be activated from a FoxPro form ?

Status
Not open for further replies.

TerDavis

Technical User
Sep 18, 2002
36
US
Hi,

We are in the process of deciding to move into Visual Basic.
We are wondering if it is possible to create forms in visual basic and combine these with the foxpro forms ?

So for a simple case, if we want to display a simple form that was created in visual basic displaying 'Hello World'.
Can we activate this form from a button click event on
a foxpro form ???

Thanks,
Ter

 
TerDavis

Essentially no. Although there are OCX that are created in VB that can be used in VFP. Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Hi TerDavis,

I dont know the practicality... since ultimately you may not want to leave a form as a form in the distribution, but may comiple that to an executable...

But so long, it remains a form, you can activate that.. in this way..


myVBForm = "VBformToRun"
DECLARE INTEGER ShellExecute IN shell32.dll ;
INTEGER hndWin, STRING cAction, STRING cFileName, ;
STRING cParams, STRING cDir, INTEGER nShowWin
ShellExecute(0,"open",myVBForm,"","",1)

** make sure that run time VB libraries are available.
:) ramani :)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
Merry Christmas & Happy New Year [bigears] [party] [2thumbsup]

 
TerDavis,

and why would anybody in the RDBMS business decide to move from Fox - which is designed for RDBM and based on SQL - to Visual Basic which is not suited/designed for handling RDB at all?! You guys are just opening a can of worms that would eat you alive! I know, I work in both

As for your question - no, you can't run VFP forms in VB, neither VB forms in VFP. In VB a form is a script, essntially (just open FRM file in Notepad, it's pure text); in VFP form is procedural file + crossreference table.

Regards,

Ilya
 
Hi IRABVY or Mike,

1. Just curiosity.. It appears my suggestion will not work as you two post that it is not possible.
2. But I feel ShellExeccute() can be done to run a file, but may be the way I specified was wrong. (I have not worked in VB and so only posted a probably approach). When ShellExecute can associte a file type with a spopecific loader and run a file, why cant it be used to run a VB form. There must be a way out. (Again it is not a question of worth it or not.. but curiosity).
3. May be if there is command switch in VB to run the form rather than opening a form which can be included in the command? Any of you having VB can test that. I will test after a few days, but not now as I dont have a VB with me right now.
:)
ramani :)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
Merry Christmas & Happy New Year [bigears] [party] [2thumbsup]

 
Ramani

1. Just curiosity.. It appears my suggestion will not work as you two post that it is not possible.

The problem with VB and most likely the reverse is true with VFP, is when you run the VB form (which needs the VB environment to run as would a VFP form), it loads VB form designer along with it. I don't think that is the desired effect.
Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Comparing VB forms with VFP forms is comparing apples with peaches (or whatever the correct expression is ;-) ).
(see also IRABYY's comment).

The only way you are able to instantiate either forms in the other environment is via a DLL or OCX.

So yes, you can instantiate a form created in VB in the click event of a fox application. If the VB form would be in a dll and you call a procedure in that dll that instantiates that form, it would be a VB form in VFP.

But you would have to make a dll in which your VB forms reside. I do not think that would be a very handy approach.

What is usually done is f.e. a 3 Tier design.

VB preentation layer
VFP business layer
SQL database

In this design situation you would have VB forms, calling a com server written in VFP that communicates with a SQL database layer.

HTH,

Weedz (Edward W.F. Veld)
My private project:Download the CrownBase source code !!
 
If you create a VB dll and place some code that can be accessed by VFP (or any language for that matter) and that basically fires a form you can run a VB form in VFP.

The reverse, using this method to run a VFP form contained in a VFP dll is not possible, what you can do however is:

Create a form that runs as top form
(topform.scx in c:\MyApp)
Then:
oVFP = CREATEOBJECT("VisualFoxPro.application")
oVFP.docmd("Do form c:\MyApp\topform.scx")

This is code you can run from any tool that can be a OLE client.

HTH
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top