Computer Engineers

 
Home | Computer engineering other top | Fiber / Wireless / Copper Tran | Semiconductor engineering
  Position:HOME>Programming language engineeri>Article Content
Visual Basic
Source:Internet Author:Unknow Pubdate:2008-04-14  
wareagle (Electrical) 29 May 04 16:13
I have several electrical programs written in Turbo Pascal.
I want to rewrite these and was thinking of using Visual Basic. I need pointers and pointer records. Is this the proper package to do this? I haven't written using VB before.

FrancisL (Computer) 30 May 04 9:21
It should be vastly easier than Turbo Pascal, apart from the learning curve.
For pointers and pointer records you have a large choice - VB has Arrays of many sorts, or probably better you can use a database to store your data.

scottydoesntknow (Computer) 10 Aug 04 14:34
wareagle,
FrancisL is right, you might want to use a database of some sort with VB.  You CAN use pointers in vb, but the method is a little bit of a hack and not really necessary unless you are sorting objects of moderate size.  vb should be relatively easy for you to pick up if you have any programming experience at all.  Just be careful, unless you are using .NET, the older vb's have some interesting quirks...
字串7


nbucska (Electrical) 13 Aug 04 18:57
I think "C" would be easier.
Can you describe the problem and perhaps E-mail the program ?
<nbucska@pcperipherals DOT com> subj: eng-tips

hdingman (Computer) 23 Aug 04 23:58
If you know pointers in C, you DON'T know pointers in VB. Bluntly, it's difficult to use pointers in VB, and I've had a lot of problems with memory leaks trying to use pointers and SET POINTERNAME=NEW(OBJECT) / SET POINTERNAME=NOTHING. For linked lists and insertion sorts, VB is OK, but don't try to do high-speed calculations indexed into the record.

Translating from Pascal to C/C++ is not difficult, and will probably have a lot less headaches if you use them rather than VB. They two languages are so similar that there are several "PAS2C.H" files filled with "#define"s that can (crudely) make Pascal source compile on a C compiler. There are plenty of test tools to write a good clean fast routine and debug it.  
字串1


VB's overhead to get to storage is a lot more than C, and VB also does nasty things like word-alignment in a record without telling you. If you try to use "real" pointers into a record, you can get into trouble fast.

C has "real" pointer types, VB does not. VB records and pointer records are a comprimise at best. VB record processing together with opening a database adds a LOT of system overhead. If you're using pointers to create work-in-process results, then do you want them in nanosecond-access RAM or millisecond-access database disk storage? If performance is an issue, I would (and do) use C. If the calculations are repetitive and you want to store/lookup rather than recalculate results, then VB-over-DB is probably fine.

If your program is a simple formula calculator, type in some values and get a result, then VB is an easy language to rewrite your program. When repetitive or reentrant engineering calculations make VB unbearably slow, move to C/C++. Or, just save the headaches and start in C.

字串6



So... What's an "electrical program?" Are you calculating and balancing dynamic loads on a power grid, or solving resistance values in Ohm's law?

Howard

someonesdad (Computer) 21 Dec 04 23:24
One option is to not translate it at all.  I haven't used it, but the MinGW distribution comes with a Pascal compiler (IIRC, it might be an early version).  I used MinGW as my default C/C++ compiler on my Windows 2000 box.  Check out http://www.mingw.org/.

Also, a Pascal to C translator program called p2c has existed for many years.  Check out e.g. http://packages.debian.org/unstable/devel/p2c.html.

One advantage of VB is that you can quickly come up with forms and an application.  That may make it worth the effort, but you'll likely have to rewrite your app from scratch.  You don't say whether it's a console program or a Windows program (likely a console program if done with Turbo Pascal).  I frankly have to admit I was seduced by VB6 a few years ago and decided to translate a C app I had written into VB.  I ultimately had numerous problems, one of which was a crashing application after installing a service pack.  I finally dumped VB in disgust.  While it's definitely capable of producing useful applications, your knowledge and effort of learning the thousand and one details aren't transferable to another system.  From that standpoint, using a language like C++ makes more sense (of  course, every language comes with some kind of baggage...). 字串9


(Click:

Previous:Porting a Windows NT C++ app to XP platform   Next:Convert Excel to PDF
[Add TO Favorites] [TOP] [PRINT] [CLOCE WINDOWS]  
  Hot Article
·PIC code for triac light dimme
·Connecting a Footswitch to an
·Siemens s7-200 PLC & Visua
·TETRIS source code is availabl
·XML Files and Terramodel
·controlling GPIB from VBA
·LINKING MSC PATRAN WITH INTRAN
·How to interface RS-485 / Modb
·VBA WITH AB PLC
·SIEMENS: I/O, NCDDE AND DCTL
·getch() function
·Visual Basic Serial Comms To S
  Related Articles
·Convert Excel to PDF
·Automatic delete files
·Prolog help
·C win32 threads
·how to make use of the results
·GTCO-Calcomp & USB to serial a
·E1055: Unable to open 'windows
·MsgBox in VB6
·Anyone use LoadLibrary
·How to create a bootable PC ca
·Needed Help with SQL Syntax
·LPT port in VB 5
Power by DedeCms