User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C section within the Software Development category of DaniWeb, a massive community of 429,965 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,516 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C advertiser: Programming Forums
Views: 6859 | Replies: 5
Reply
Join Date: Jun 2004
Posts: 5
Reputation: minnie is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
minnie minnie is offline Offline
Newbie Poster

Converting from VB code to C

  #1  
Jun 25th, 2004
Is it possible to convert from VB code to C and what is the best way to do this?
AddThis Social Bookmark Button
Reply With Quote  
Join Date: May 2004
Location: Boston,MA
Posts: 1,362
Reputation: mikeandike22 is an unknown quantity at this point 
Rep Power: 7
Solved Threads: 17
Featured Blogger
mikeandike22's Avatar
mikeandike22 mikeandike22 is offline Offline
Nearly a Posting Virtuoso

Re: Converting from VB code to C

  #2  
Jun 25th, 2004
--------------------------------------------------------------------------------

the following VB code, and 'speed' is an integer:

Select Case speed
Case 0 to 10
(code that executes if speed is between 0-10)
Case 11 to 59
(code that executes if speed is between 11-59)
Case 60
(code that executes if speed is exactly 60)
Case 80
(code that executes if speed is exactly 80)
Case Else
(code that executes if speed is anything else)

Now suppose that you are responsible for converting the code to C. The speed variable is now a float. In addition, your boss tells you that, in addition to the values above in the VB code, you must check for a speed of 98.6 and do some extra code if the speed is that value.

First, discuss how you would go about converting this code, explaining why you're making the choices you think you need to make.

Second, what does the C code look like?


I have a problem converting this to C, since we have one case that checks for values between 0 and 10 and another case that checks for values from 11 to 59. So what happens when a value is 10.5? It is skipped completely.

Should the code would look something like this:

if (speed < 10)
printf("A \n");
else if (speed > 10 && speed < 60)
printf("B \n");
My Daniweb Blog: This,That, and Everything Else (Blog contest winner)

GetFirefox!
GetOpera!






Reply With Quote  
Join Date: Jun 2004
Posts: 5
Reputation: minnie is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
minnie minnie is offline Offline
Newbie Poster

Re: Converting from VB code to C

  #3  
Jun 25th, 2004
Do not understand your reply
Reply With Quote  
Join Date: Jun 2004
Location: Marin, CA, USA
Posts: 434
Reputation: Chainsaw is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 10
Chainsaw's Avatar
Chainsaw Chainsaw is offline Offline
Unprevaricator

Re: Converting from VB code to C

  #4  
Jul 6th, 2004
I'm not aware of any automated tools to convert vb to c, so you're stuck knowing both languages and translating by hand. Maybe a good Google search would help find some tools to aid translation.

It would be easier converting vb to vc++, because you could at least stick to some of the class usages.

And, ick, if the VB code does any COMM work, it will be MUCH harder in C.

Are you sure conversion is better than 'rewrite'?
Reply With Quote  
Join Date: Oct 2004
Location: Mojave Desert
Posts: 2,477
Reputation: vegaseat will become famous soon enough vegaseat will become famous soon enough 
Rep Power: 10
Solved Threads: 176
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
Kickbutt Moderator

Solution Re: Converting from VB code to C

  #5  
Oct 3rd, 2004
Originally Posted by minnie
Is it possible to convert from VB code to C and what is the best way to do this?


visit: http://bcx.basicguru.com/

and get a hold of BCX. Kevin Diggins migrated from VB to C/C++ a few years ago and wrote BCX, a basic to C translator that has been updated and improved ever since. Some members of the BCX group have actually written a VB to BCX translator. The whole thing is absolutely free, comes with a great help file, and has all source code with it! Check it out! The BCX folks maintain a very active group at:
http://groups.yahoo.com/group/bcx/
Reply With Quote  
Join Date: Oct 2004
Location: Mojave Desert
Posts: 2,477
Reputation: vegaseat will become famous soon enough vegaseat will become famous soon enough 
Rep Power: 10
Solved Threads: 176
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
Kickbutt Moderator

Solution Re: Converting from VB code to C

  #6  
Oct 13th, 2004
I looked back into my rusty memory and noticed that there is a program written by Bill Gate's minions that translates Visual Basic to Visual C++. Check:

http://support.microsoft.com/default.aspx?kbid=216388
May 'the Google' be with you!
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb C Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the C Forum

All times are GMT -4. The time now is 11:39 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC