2 Replies - 3889 Views - Last Post: 16 January 2012 - 05:11 PM Rate Topic: -----

#1 SpeedwayNative  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 21-March 11

Need to convert a Console Application to a Windows Forms Application

Posted 16 January 2012 - 12:16 AM

OK, so I am in my 1st semester of C++. I have already finished my 1st assignment (below), a Windows32 Console Application and it works just fine. However, if I write the program as a Windows Forms Application with a GUI, then I can earn extra credit. My problem is that I can't seen to output the assignment to a label. I have created the GUI, but only being in my 1st week of class, I am unaware how to output the same info that the Console Application displays in a label box in the GUI in a Windows Form. I need to display the following 4 items. Any help would be greatly appreciated!

// Restaurant Bill.cpp : Diplays the meal cost, tax amount, tip amount, and total bill on the screen
//

#include "stdafx.h"


#include <iostream>
using namespace std;


int main()
{
	double meal = 44.50;
	double tax = meal * 0.0675;
	double subtotal = meal + tax;
	double tip = subtotal * 0.15;
	double total = subtotal + tip;

	cout <<"Meal cost: " << meal << endl;
	cout <<"Tax Amount: " << tax << endl;
	cout <<"Tip Amount: " << tip << endl;
	cout <<"Total: " << total << endl;

	return 0;
}


Is This A Good Question/Topic? 0
  • +

Replies To: Need to convert a Console Application to a Windows Forms Application

#2 no2pencil  Icon User is online

  • Toubabo Koomi
  • member icon

Reputation: 5224
  • View blog
  • Posts: 26,991
  • Joined: 10-May 07

Re: Need to convert a Console Application to a Windows Forms Application

Posted 16 January 2012 - 12:52 AM

It's not as simple as 'converting' the code. You need to use the Windows API to create a class.

You should check over Aphex19's Windows API tutorial series :

Intro
Intro part 2
Intro part 3
Was This Post Helpful? 0
  • +
  • -

#3 #define  Icon User is offline

  • Duke of Err
  • member icon

Reputation: 1325
  • View blog
  • Posts: 4,551
  • Joined: 19-February 09

Re: Need to convert a Console Application to a Windows Forms Application

Posted 16 January 2012 - 05:11 PM

Hi, SpeedwayNative.

View PostSpeedwayNative, on 16 January 2012 - 09:16 AM, said:

... However, if I write the program as a Windows Forms Application with a GUI, then I can earn extra credit. ...


Is this is what you want? How to: Create a Windows Forms Application.

Notice label takes a string so the number (double) needs to be converted. There are several ways to do that, there the String.Format Method is used.

label1->Text=String::Format("New date: {0}", dateTimePicker1->Text);


I'll let you try and do it, if you need more help just shout.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1