View Full Version : covert from Visual C++ to Vb.net


khaty79
06-15-03, 11:22 PM
hello... frenzz, i dont know how to convert from visual C++ to vb.net... it is possible to do it??? cna all of u help me.. urgent!!

#include <iostream>
using namespace std;

class ADTstack
{
private:
int stack[5];
int topstack;
int num;

public:
ADTstack ()
{topstack = -1;}
int empty ()
{
if (topstack == -1)
return 1;
else
return 0;
}

int full ()
{
if (topstack == 5)
return 1;
else
return 0;
}

void push (int num)
{
if (!full ())
{
topstack++;
cout << " \n inserting " << num ;
stack[topstack] = num;
}
else
cout<<"Stack is full"<<endl;
}

int pop ()
{
int num;
if (!empty ())
{
num = stack[topstack];
topstack--;
return num;
}
else
{
cout<<"Stack is empty"<<endl;
return 0;
}
}
};

class ADTstackB
{
private:
int stack[5];
int topstack;
int num;

public:
ADTstackB ()
{topstack = -1;}
int empty ()
{
if (topstack == -1)
return 1;
else
return 0;
}

int full ()
{
if (topstack == 5)
return 1;
else
return 0;
}

void push (int num)
{
if (!full ())
{
topstack++;
stack[topstack] = num;
}
else
cout<<"Stack is full"<<endl;
}

int pop ()
{
int num;
if (!empty ())
{
num = stack[topstack];
topstack--;
return num;
}
else
{
cout<<"Stack is empty"<<endl;
return 0;
}
}
};

class LinkList
{
public:
int list[5];
int pre;
int post;

public:
LinkList ()
{
pre = 0;
post = 0;
}

void addElement (int pre11 , int post11 , int value11)
{
if ( pre == post )
{
list[pre]=value11 ;
cout << " \n inserting to link list at index " << pre << " value == " << list[pre] ;
}
else
{
list[post11] = value11 ;
cout << " \n inserting to link list at index "<< post << " value == " << list[post11];
}
post++ ;
}

void pretraverse ()
{
for ( int i = pre ; i < 5 ; i++ )
{
int retval = list[i];
cout << " \n index == " << i << " value == " << retval ;
}
}
};


void main ()
{
int c;
const int True = 1, False = 2;
ADTstack s;
ADTstackB t;
LinkList mylist ;
int op = 0;
//int sameOP = True; // assume string with same action
cout << " \n Creating stack " ;
for(op=0; op<5; op++)
s.push(op);

//now pop stack,comparing pre and post action of each operator.
// and create a link list
cout << " Stack has created ";
cout << " \n inserting to link list " ;
while(!s.empty())
{
c = s.pop(); //get next operator from stack
//then, insert the node of linked list
cout << " \n processing " << c ;
mylist.addElement(mylist.pre , mylist.post , c ) ;
}

cout << " \n Link list has created successfully " ;

cout << " \n Here is the output from Link List using pre pointer " ;

mylist.pretraverse() ;

cout << " \n finished " ;
}

AntonK
06-16-03, 12:54 AM
It is possible, it will just be different. All major datastructures can be done in any language, the implementation is just different. How well versed are you in C++, how well versed are you in VB? Does it specifically need to be VB.net? or can it be VB? I'm pretty sure there were soem new things implemented in VB.net that wasnt in the previous versions.

-AntonK

Blindman
06-16-03, 07:49 AM
If you have the Dotnet IDE just convert it to a C++.NET or C#.NET. You can include your C code in VB.NET. Just turn it into a DLL and include it in your VB project (Drag and drop is the easiest way). Its all way to easy now.

Also if it must be converted to VB try looking on the net, there are a few programs that will convert languages. Not that I can remeber any names.

For such a little amount of code your best of doing it by hand.

khaty79
06-16-03, 08:17 PM
thanks guys:D
but the software DOTNET IDE can be found in the internet...?? it is the free sofware of joining with others vb software???

Blindman
06-16-03, 10:39 PM
DOTNET IDE (Integrated Development Environment) is not free.

You will have to contact Microsoft or a good software supplier. It is a very large install (almost 2Gig) and is usually supplied on a DVD. Make sure you have a DVD player or ask for a CD copy.

My copy cost me $1500AUS ($850US) so it is not something you buy just to have fun with.