Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > VB to C++ conversion

Reply
Thread Tools

VB to C++ conversion

 
 
Alex
Guest
Posts: n/a
 
      12-03-2004
I need to transfer a Visual Basic program to C++ (stop laughing at the
use of VB, as I didn't write it). The program in question is ~3500
lines long, so it would be VERY unpleasant to convert it by hand. In
adition, only the sintax on a line to line basis needs be transfered as
this program is almost entirely computational, no UI or anything more
complicated than If, For, Case and While statements. Essentially, I am
looking for a sintax converter. Does anyone know of any?

 
Reply With Quote
 
 
 
 
Phlip
Guest
Posts: n/a
 
      12-03-2004
Alex wrote:

> I need to transfer a Visual Basic program to C++ (stop laughing at the
> use of VB, as I didn't write it). The program in question is ~3500
> lines long, so it would be VERY unpleasant to convert it by hand. In
> adition, only the sintax on a line to line basis needs be transfered as
> this program is almost entirely computational, no UI or anything more
> complicated than If, For, Case and While statements. Essentially, I am
> looking for a sintax converter. Does anyone know of any?


If the program is purely computational, follow this strategy. Download a
light C++ unit test rig, such as NanoCppUnit or CppUnitLite.

(CppUnit itself is hard to use, and somewhat derivative.)

Write a test case that calls system() or popen(), and calls the legacy VB
program's executable.

Pass to that program its simplest possible input. Collect the output into a
string, or something, and parse out its numbers.

(At this point, if you are completely adept at ActiveX, you could build a
DLL in VB and call it from ATL in C++, but don't even start without at least
a year's experience in COM in C++...)

Now your test case is going to call a new C++ function, that does not exist
yet. Pass into the function that same simplest input, and collect its
output. Write an ASSERT_EQUAL() statement that matches the new output to the
legacy output.

Run the test and predict failure.

Now add the minimum amount of C++ code required to pass that test.

Write another test case, and repeat this procedure for each of the source
code's abilities.

Stop occassionally to refactor the C++, running the tests after the fewest
possible edits. Extract duplicated statements into new methods. Along this
process, objects may appear. They might not be the same as the objects in
the legacy VB code. This is a good thing.

I used that technique, between BASIC and Ruby, to extract an old LParser
algorithm and produce this project:

http://flea.sourceforge.net/

--
Phlip
http://industrialxp.org/community/bi...UserInterfaces





 
Reply With Quote
 
 
 
 
Ioannis Vranos
Guest
Posts: n/a
 
      12-03-2004
Alex wrote:

> I need to transfer a Visual Basic program to C++ (stop laughing at the
> use of VB, as I didn't write it). The program in question is ~3500
> lines long, so it would be VERY unpleasant to convert it by hand. In
> adition, only the sintax on a line to line basis needs be transfered as
> this program is almost entirely computational, no UI or anything more
> complicated than If, For, Case and While statements. Essentially, I am
> looking for a sintax converter. Does anyone know of any?



If your program is written in VB .NET, then you may encapsulate it to a
class (if it isn't), and make it a .NET dll which will be callable from
C++ (and any other .NET language).

Then you can continue developing it in C++.




--
Ioannis Vranos

http://www23.brinkster.com/noicys
 
Reply With Quote
 
Phlip
Guest
Posts: n/a
 
      12-03-2004
Ioannis Vranos wrote:

> > I need to transfer a Visual Basic program to C++ (stop laughing at the
> > use of VB, as I didn't write it). The program in question is ~3500
> > lines long, so it would be VERY unpleasant to convert it by hand. In
> > adition, only the sintax on a line to line basis needs be transfered as
> > this program is almost entirely computational, no UI or anything more
> > complicated than If, For, Case and While statements. Essentially, I am
> > looking for a sintax converter. Does anyone know of any?

>
>
> If your program is written in VB .NET, then you may encapsulate it to a
> class (if it isn't), and make it a .NET dll which will be callable from
> C++ (and any other .NET language).
>
> Then you can continue developing it in C++.


Doesn't that give you the choice of either Managed C++ or #import and all
the COM wrapper stuff?

--
Phlip
http://industrialxp.org/community/bi...UserInterfaces


 
Reply With Quote
 
Alf P. Steinbach
Guest
Posts: n/a
 
      12-03-2004
* Alex:
> I need to transfer a Visual Basic program to C++ (stop laughing at the
> use of VB, as I didn't write it). The program in question is ~3500
> lines long, so it would be VERY unpleasant to convert it by hand. In
> adition, only the sintax on a line to line basis needs be transfered as
> this program is almost entirely computational, no UI or anything more
> complicated than If, For, Case and While statements. Essentially, I am
> looking for a sintax converter. Does anyone know of any?


Since nobody's mentioned this yet, there are VB to Java converters, and
there are Java to C++ converters. Google (I did, earlier, but got
sidetracked by something else). Probably it won't work but might be
worth a try -- let us know...

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
 
Reply With Quote
 
Ioannis Vranos
Guest
Posts: n/a
 
      12-03-2004
Phlip wrote:

> Doesn't that give you the choice of either Managed C++ or #import and all
> the COM wrapper stuff?



I did not understand the question. May you explain what do you mean?

As a note, "Managed C++" is not the official term (although this term is
also used even in some MS sites). The official term is "managed extensions".

In the current version of VS, ISO C++ code compiles in CLR mode, however
you can not use all ISO C++ features on managed types.

Things will improve in VS 2005 (templates will be able to be used on
managed types along with generics), and vastly improve in the release
after that.


In any case, ISO C++ code compiles everywhere including .NET.




--
Ioannis Vranos

http://www23.brinkster.com/noicys
 
Reply With Quote
 
Ioannis Vranos
Guest
Posts: n/a
 
      12-03-2004
Ioannis Vranos wrote:

> I did not understand the question. May you explain what do you mean?



I rechecked it and I think you mean that it leaves us with either
"managed extensions" (and upcoming C++/CLI which will replace them), or
COM and other unmanaged stuff.

Actually this is not exactly the case. It leaves us with either "managed
extensions" *and* ISO C++, or ISO C++ and the other unmanaged stuff.

More precisely, the other unmanaged stuff can also be compiled in
managed mode.


However ISO C++ can be entirely managed and this will be the case in the
upcoming releases, since also C++ becomes the systems programming
language of .NET!

An example using the current Beta of VC++ 2005:


inline int add(int x, int y) { return x+y; }


int main()
{
int a=add(1,2);
}


C:\c>cl /clr:safe temp.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 14.00.41013
for Microsoft (R) .NET Framework version 2.00.41013.0
Copyright (C) Microsoft Corporation. All rights reserved.

temp.cpp
Microsoft (R) Incremental Linker Version 8.00.41013
Copyright (C) Microsoft Corporation. All rights reserved.

/out:temp.exe
temp.obj

C:\c>




The /clr:safe means that this code is 100% CLR verified and thus is
binary portable to all CLI VMs (Mono, DotGNU, etc). That is, it is pure
CLI bytecode.


It does not contain any native code.




--
Ioannis Vranos

http://www23.brinkster.com/noicys
 
Reply With Quote
 
Phlip
Guest
Posts: n/a
 
      12-03-2004
Ioannis Vranos wrote:

> It does not contain any native code.


I just meant that either the OP must learn the old-fashioned #import stuff,
commonly called "ATL", or they must bond their application with .NET just to
get a link between a VB module and a C++ one.

OTOH it sounds like Microsoft _finally_ invented a p-code they can live
with...

--
Phlip
http://industrialxp.org/community/bi...UserInterfaces


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
PSD to XHTML Conversion Services and PSD to HTML CSS ConversionServices, PSD to Joomla, Drupal, Wordpress Conversion xhtml champs Python 0 06-21-2011 11:59 AM
PSD to XHTML Conversion Services and PSD to HTML CSS ConversionServices, PSD to Joomla, Drupal, Wordpress Conversion PSD to XHTML Conversion Services and PSD to HTML CSS Conversion Services, PSD to Joomla, Drupal, Wor VHDL 0 04-25-2011 06:43 AM
conversion operator and conversion ctor subramanian100in@yahoo.com, India C++ 2 09-15-2009 12:46 PM
Date conversion problem with OE importing saroxonline76@vodafone.it Firefox 0 07-12-2005 07:38 PM
Framework 1.0 to 1.1 conversion Luc Bisson ASP .Net 2 11-19-2003 02:40 AM



Advertisments