![]() |
Plz Help - Visual Basic .net/visual C++ .net Code
Hi! Plz help anyone!!! I wrote this program from a visual basic .net book. It works fine but when i wanna write the same program using visual c++ .net code i get errors. Im using Visual studio.net 2003
:
Private Sub ExitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitButton.Click |
Quote:
|
I hope you know this but...
C++ .NET is not VB .NET big syntax difference there just a few examples (semicolons, no "dim", etc, etc) you're pretty much going to have to re-write the whole thing if you want to run it in C++. |
Quote:
|
Then post your code you wrote in C++ and we will do our best.
|
Have you imported the right libraries. Because if you did everything should work fine. It is not difficult to translate between .NET languages. But you must know something else, if you want to compile the code in visual studio you must compile it with /clr(in the console) or enable the clr in the project options.
|
Well its not a console appliction, its a windows form app. And if u look at the VB code at the top, the calcButton event at the for loop, by trying to write the same thing with c++ code, it gives errors
:
int hours |
The error message is pretty clear. Check the prototype for Add and explicitly convert 'hours' to an object of that type. You might consider resorting to your help files, using the term, "C2664". Just a thought.
|
I haven't done much work with the C++ .NET interface, but you probably have to do something like:
:
System::Int32 hours; |
You might need to explicitly 'box' the int. I'm not sure if VC++ boxes and unboxes stuff automagically, whereas C# does (which has good and bad sides). Try casting it to System::Object first, like so:
:
this->HoursListBox->Items->Add((System::Object)hours); |
| All times are GMT -5. The time now is 3:51 PM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC