Sign in to follow this  

My first Project attempt (C++ Need Help)

This topic is 2392 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So hi!

I'm new to the foum (registering anyway) and I need some help. I know this doesn't pertain strait to game programming but it is a programming problem.

I'm creating a calculator that calculates how much it costs when districts or schools increase their levies.
The problem is indicated where nPriceReduction starts.



[code]//The purpose of this program is to show my community (and any if that) how inexpensive levy increases are.
//This will eventually become a windowed program.
#include <iostream>
#include <conio.h>

using namespace std;

int main(){
cout << "Please enter your house's market value" << endl;
int nY; // Market value of house
cin >> nY;
cout << "Please enter the number of mills" << endl;// For those unfamiler with mills, 1 mill = 1% increase.
int nZ;
cin >> nZ;
int nNumberOfMills = nZ;
int nTaxPercent = .35;
float nX = nY * nTaxPercent;//Takes the market value of house and multiplies it by the percent of the house you pay taxes on.
float nMill = .001;// 1% = 1 mill
float nMillCalc = nZ * nMill;//Multiplies the value of a mill by how many there are.
cout << "Are you getting a goverment price reduction?(true/false)" << endl;
//Having trouble with this section, I essentially want the user to type yes/no and for it to do the correct if statement apropriatly.
//When I execute this it always assumes the answer is false.
bool nPriceReduction;
cin >> nPriceReduction;
if (bool nPriceReduction = true){
cout << "Your proporty taxes cost for " << nZ << " mill(s) is {:content:}quot; << nMillCalc * nX * .875 << " per year or {:content:}quot; << ((nMillCalc * nX * .875) / 12) << " per month " << endl;

}else if (char nPriceReduction = false){
cout << "Your proporty taxes cost for " << nZ << " mill(s) is {:content:}quot; << nMillCalc * nX << " per year or {:content:}quot; << ((nMillCalc * nX) / 12) << " per month " << endl;}
getch();
return 0;
}
[/code]

Share this post


Link to post
Share on other sites
I would like the user to be able to enter the word yes so they don't get confused with it, on a side note if anyone could point me towords making this in a window with GUI that would be great.

Share this post


Link to post
Share on other sites
what about (have not tested this so there could be errors)

[code]
cout << "Are you getting a goverment price reduction?(Yes / No)";
string d;
cin >> d;
if(d == 'string("yes")')
nPriceReduction = true;
else
nPriceReduction = false;
[/code]
or more simply
[code]
cout << "Are you getting a goverment price reduction?(Y / N)";
char d = 'n';
cin >> d;
if(d == 'y')
nPriceReduction = true;
else
nPriceReduction = false;
[/code]

that better ?

Share this post


Link to post
Share on other sites
[quote name='xaviarrob' timestamp='1306351294' post='4815727']

[code]
bool nPriceReduction;
cin >> nPriceReduction;
if (bool nPriceReduction = true){
cout << "Your proporty taxes cost for " << nZ << " mill(s) is {:content:}quot; << nMillCalc * nX * .875 << " per year or {:content:}quot; << ((nMillCalc * nX * .875) / 12) << " per month " << endl;

}
[/code]
Perhaps what you meant was this?
[code]
bool nPriceReduction;
cin >> nPriceReduction;
if (nPriceReduction){
// ...
}
[/code]
What you have declares a temporary variable and assigns it the value true, all inside the expression of your if-statement.
[/quote]

Share this post


Link to post
Share on other sites
[quote name='ryan20fun' timestamp='1306351863' post='4815733']
what about (have not tested this so there could be errors)

[code]
cout << "Are you getting a goverment price reduction?(Yes / No)";
string d;
cin >> d;
if(d == 'string("yes")')
nPriceReduction = true;
else
nPriceReduction = false;
[/code]
or more simply
[code]
cout << "Are you getting a goverment price reduction?(Y / N)";
char d = 'n';
cin >> d;
if(d == 'y')
nPriceReduction = true;
else
nPriceReduction = false;
[/code]

that better ?
[/quote]

When compiling this since there is nothing terminating that else everything beyond the tags evaluates to 0.

Share this post


Link to post
Share on other sites
[quote name='Bregma' timestamp='1306352171' post='4815738']
[quote name='xaviarrob' timestamp='1306351294' post='4815727']
[code]
bool nPriceReduction;
cin >> nPriceReduction;
if (bool nPriceReduction = true){
cout << "Your proporty taxes cost for " << nZ << " mill(s) is {:content:}quot; << nMillCalc * nX * .875 << " per year or {:content:}quot; << ((nMillCalc * nX * .875) / 12) << " per month " << endl;

}
[/code]
Perhaps what you meant was this?
[code]
bool nPriceReduction;
cin >> nPriceReduction;
if (nPriceReduction){
// ...
}
[/code]
What you have declares a temporary variable and assigns it the value true, all inside the expression of your if-statement.
[/quote]
[/quote]
I dont quite understand what you mean here

Share this post


Link to post
Share on other sites
if (bool nPriceReduction = true)

1) You do not need to specify the data type in an if statement; nPriceReduction is already a bool data type.
2) Since nPriceReduction is already a bool data type you can simply say "if (nPriceReduction) {}"
3) Always use the "equal to" (==) when doing a comparing value(s) and not the assignment operator (=)


For instance:
if (nPriceReduction = true) will always assign true to nPriceReduction and will always evaluate as true
if (nPriceReduction == true) will always compare nPriceReduction to see if it is true or false (== is equal to; != is not equal to)

That is what the other members were talking about.

Share this post


Link to post
Share on other sites
[quote name='UltimaX' timestamp='1306353888' post='4815750']
if (bool nPriceReduction = true)

1) You do not need to specify the data type in an if statement; nPriceReduction is already a bool data type.
2) Since nPriceReduction is already a bool data type you can simply say "if (nPriceReduction) {}"
3) Always use the "equal to" (==) when doing a comparing value(s) and not the assignment operator (=)


For instance:
if (nPriceReduction = true) will always assign true to nPriceReduction and will always evaluate as true
if (nPriceReduction == true) will always compare nPriceReduction to see if it is true or false (== is equal to; != is not equal to)

That is what the other members were talking about.
[/quote]


Thanks a bunch this is exactly the answer I wanted. If anyone could point me in the direction of translating all of this out of console and into a window I would much appriciate it!

Share this post


Link to post
Share on other sites
[quote name='xaviarrob' timestamp='1306354331' post='4815753']
Thanks a bunch this is exactly the answer I wanted. If anyone could point me in the direction of translating all of this out of console and into a window I would much appriciate it!
[/quote]


The code for doing all of the work is going to be the same whether it's in a window or not. You can use the Windows libraries to put a window together ([url="http://www.winprog.org/tutorial/"]tutorial[/url]) for a simple interface. Depending on all of the stuff you want in the window, SFML might be an OK way to go too. It's easier, at any rate.

Share this post


Link to post
Share on other sites
[quote name='Khaiy' timestamp='1306361584' post='4815794']
[quote name='xaviarrob' timestamp='1306354331' post='4815753']
Thanks a bunch this is exactly the answer I wanted. If anyone could point me in the direction of translating all of this out of console and into a window I would much appriciate it!
[/quote]


The code for doing all of the work is going to be the same whether it's in a window or not. You can use the Windows libraries to put a window together ([url="http://www.winprog.org/tutorial/"]tutorial[/url]) for a simple interface. Depending on all of the stuff you want in the window, SFML might be an OK way to go too. It's easier, at any rate.
[/quote]

All I want in the window is a few text boxes to enter the values, a check box for making something true/false, and an area for information on the side so whatevere is easiest.

Share this post


Link to post
Share on other sites
&gt; All I want in the window is a few text boxes to enter the values, a check box for making something true/false, and an area for information on the side so whatevere is easiest.  

You are not ready to do this. You would have to pick a third party library that provides this support. It's called a widget toolkit. The most basic library is the Windows API itself, but there are others like FLTK, GTK+, Qt, etc.  

You are not ready to use third party libraries.

Share this post


Link to post
Share on other sites
[quote name='xaviarrob' timestamp='1306361911' post='4815796']
[quote name='Khaiy' timestamp='1306361584' post='4815794']
[quote name='xaviarrob' timestamp='1306354331' post='4815753']
Thanks a bunch this is exactly the answer I wanted. If anyone could point me in the direction of translating all of this out of console and into a window I would much appriciate it!
[/quote]


The code for doing all of the work is going to be the same whether it's in a window or not. You can use the Windows libraries to put a window together ([url="http://www.winprog.org/tutorial/"]tutorial[/url]) for a simple interface. Depending on all of the stuff you want in the window, SFML might be an OK way to go too. It's easier, at any rate.
[/quote]

All I want in the window is a few text boxes to enter the values, a check box for making something true/false, and an area for information on the side so whatevere is easiest.
[/quote]

download visual studio express c++ (or c# if you want to give it a try)
create a new project, chose windows program, and start dragging textboxes and buttons in there.
then just double click on a button, and it will take you to the "on click" event for the button. Then you can just write Textbox1.text = "hello world"
or something similar, and there you have it, a window

Share this post


Link to post
Share on other sites
[quote name='oler1s' timestamp='1306369424' post='4815854']
&gt; All I want in the window is a few text boxes to enter the values, a check box for making something true/false, and an area for information on the side so whatevere is easiest.

You are not ready to do this. You would have to pick a third party library that provides this support. It's called a widget toolkit. The most basic library is the Windows API itself, but there are others like FLTK, GTK+, Qt, etc.

You are not ready to use third party libraries.
[/quote]

Wasn't helpful at all, Please do not post worthless information to up postcount. You do not know me and also probably didn't know I have probably about 4-5 hours onadverage I can study with. I have a basic understandng of what I needed to do and I just wanted sugguestions from others. In that regaurd thanks for the list of things I could use.

Share this post


Link to post
Share on other sites
> your posted code above and your questions.

I don't know you, but based on what I see, you're not an experienced programmer. No one's stopping you from looking at the toolkits I mentioned.

Share this post


Link to post
Share on other sites
[quote name='xaviarrob' timestamp='1306375393' post='4815875']
Wasn't helpful at all, Please do not post worthless information to up postcount. You do not know me and also probably didn't know I have probably about 4-5 hours onadverage I can study with. I have a basic understandng of what I needed to do and I just wanted sugguestions from others. In that regaurd thanks for the list of things I could use.
[/quote]

Post count isn't worth anything here, it's not even shown unless you feel like jumping into someone's profile page. No one tries to pump it up, and certainly not a longtime and well-respected member.

The amount of time you generally have to study doesn't change the fact that jumping into something too complicated before you're ready will produce slower progress and worse skills than you might otherwise have. And as oler1s mentioned you showed a code sample, which is certainly enough to vaguely evaluate your skill.

Oler1s listed several options for you, which you even thanked him for. That's not "worthless information" that "wasn't helpful at all". Don't take things so personally, and don't snap at people who even you say provide the very information that you're looking for.

Share this post


Link to post
Share on other sites
[quote name='oler1s' timestamp='1306376070' post='4815880']
> your posted code above and your questions.

I don't know you, but based on what I see, you're not an experienced programmer. No one's stopping you from looking at the toolkits I mentioned.
[/quote]

I'm very inexperianced. I'm more of one of those people who does thing to learn them, and when I run into a wall, I look for information. I have a breif basis of what I am doing and what my goal is for this project.

This project, besides being something to help my community be less ignorant of their taxes, is really to help me learn. I could look at a book, or I could expiriance the problems and try to problem solve to fix them. I just spent a half hour with a friend fixing up the code a bit. It may be a bit far to try to integrate this into a window but i'm going to try anyways. I decided I would use Visual Studio's built in Window Creator. I'm still a bit unsure on how to take my code and make the buttons use the code but i'll figure it out.

Share this post


Link to post
Share on other sites
[quote name='Khaiy' timestamp='1306378227' post='4815885']
[quote name='xaviarrob' timestamp='1306375393' post='4815875']
Wasn't helpful at all, Please do not post worthless information to up postcount. You do not know me and also probably didn't know I have probably about 4-5 hours onadverage I can study with. I have a basic understandng of what I needed to do and I just wanted sugguestions from others. In that regaurd thanks for the list of things I could use.
[/quote]

Post count isn't worth anything here, it's not even shown unless you feel like jumping into someone's profile page. No one tries to pump it up, and certainly not a longtime and well-respected member.

The amount of time you generally have to study doesn't change the fact that jumping into something too complicated before you're ready will produce slower progress and worse skills than you might otherwise have. And as oler1s mentioned you showed a code sample, which is certainly enough to vaguely evaluate your skill.

Oler1s listed several options for you, which you even thanked him for. That's not "worthless information" that "wasn't helpful at all". Don't take things so personally, and don't snap at people who even you say provide the very information that you're looking for.
[/quote]

I probably worded that completly incorrectly. I wasn't implying he was trying to up his post count, I was trying to say that telling me I couldn't do something was only worth that, if that makes sence. I understand I'm probably jumping into something too big for my knowlage and it's not like i'm not learning a lot every day. Most of the 4-5 hours I refer to is spent taking in new information and applying it in simple programs. I will openly admit I'm horrible, but, I am still learning. I wasn't trying to imply that the information about the libraries was worthless information, I was trying to refer to him telling me it wasn't going to happen. I may be new and inexpirianced but I don't need to be flammed at. As I said I found the information he did give me usefull, although I decided I shouldn't use it because I wasnt ready. I as posted above decided to use just Visual Basic's built in Library or w/e you would call it.

Share this post


Link to post
Share on other sites
I didn't know that you could use WinForms with C++, but apparently you can. It's tricky when you start, but you can still get up and running much faster than building your own stuff from scratch with the Windows API. I found a tutorial that might help you get started:

[url="http://www.visualcplusdotnet.com/visualcplusdotnet21.html"]C++ Windows Forms Tutorial[/url]

Share this post


Link to post
Share on other sites
[quote name='Khaiy' timestamp='1306385779' post='4815904']
I didn't know that you could use WinForms with C++, but apparently you can. It's tricky when you start, but you can still get up and running much faster than building your own stuff from scratch with the Windows API. I found a tutorial that might help you get started:

[url="http://www.visualcplusdotnet.com/visualcplusdotnet21.html"]C++ Windows Forms Tutorial[/url]

[/quote]


Yup found the exact same thing when I found out I could last night. Thanks for the link though. :)

Share this post


Link to post
Share on other sites
If someone could help me or direct me in how to transition my function into this form(see comments in below code) that would be awsome. I understand how the form and it's actions work, but dont get were or how to send certain information to where I want.


[code]

//The purpose of this program is to show my community (and any if that) how inexpensive levy increases are.
//This will eventually become a windowed program.

#include "stdafx.h"
#include <iostream>
#include <conio.h>

using namespace std;

int main(){
cout << "Please enter your house's market value" << endl;
int nY; // This needs to be inserted in textbox1
cin >> nY;
cout << "Please enter the number of mill(s)" << endl;// For those unfamiler with mills, 1 mill = 1% increase.
int nZ;
cin >> nZ;//Needs to go into textbox2
int nNumberOfMills = nZ;
float nTaxPercent = .35;//This needs to be hidden but needs to execute
float nX = nY * nTaxPercent;//Same as above
float nMill = .001;// 1% = 1 mill//same as above
float nMillCalc = nZ * nMill;//Multiplies the value of a mill by how many there are.same as above
cout << "Are you getting a goverment price reduction?(1=Yes, 0=No)";
bool nD;//This needs to be true/false(1 or 0) from checking a check box
cin >> nD;
//The result of these need to be inserted into the forms respectively
if (nD == 1)
cout << "Your proporty taxes cost for " << nZ << " mill(s) is {:content:}quot; << nMillCalc * nX * .875 << " per year or {:content:}quot; << ((nMillCalc * nX * .875) / 12) << " per month " << endl;

//into textbox3


if (nD == 0)
cout << "Your proporty taxes cost for " << nZ << " mill(s) is {:content:}quot; << nMillCalc * nX << " per year or {:content:}quot; << ((nMillCalc * nX) / 12) << " per month " << endl;

//into Textbox4
getch();
return 0;
}

//Above this is the actual functions I need to go into the program in
// start of the form
#pragma once

namespace blahfuckthis {

using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;

/// <summary>
/// Summary for Form1
/// </summary>
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}

protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~Form1()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Button^ button1;
private: System::Windows::Forms::CheckBox^ checkBox1;
private: System::Windows::Forms::Button^ button2;
private: System::Windows::Forms::TextBox^ textBox1;
private: System::Windows::Forms::Label^ label1;
private: System::Windows::Forms::Label^ label2;
private: System::Windows::Forms::TextBox^ textBox2;
private: System::Windows::Forms::Label^ label3;
private: System::Windows::Forms::TextBox^ textBox3;
private: System::Windows::Forms::Label^ label4;
private: System::Windows::Forms::Label^ label5;
private: System::Windows::Forms::TextBox^ textBox4;
private: System::Windows::Forms::TextBox^ textBox5;

protected:

private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(Form1::typeid));
this->button1 = (gcnew System::Windows::Forms::Button());
this->checkBox1 = (gcnew System::Windows::Forms::CheckBox());
this->button2 = (gcnew System::Windows::Forms::Button());
this->textBox1 = (gcnew System::Windows::Forms::TextBox());
this->label1 = (gcnew System::Windows::Forms::Label());
this->label2 = (gcnew System::Windows::Forms::Label());
this->textBox2 = (gcnew System::Windows::Forms::TextBox());
this->label3 = (gcnew System::Windows::Forms::Label());
this->textBox3 = (gcnew System::Windows::Forms::TextBox());
this->label4 = (gcnew System::Windows::Forms::Label());
this->label5 = (gcnew System::Windows::Forms::Label());
this->textBox4 = (gcnew System::Windows::Forms::TextBox());
this->textBox5 = (gcnew System::Windows::Forms::TextBox());
this->SuspendLayout();
//
// button1
//
this->button1->Location = System::Drawing::Point(302, 269);
this->button1->Margin = System::Windows::Forms::Padding(4);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(254, 86);
this->button1->TabIndex = 0;
this->button1->Text = L"Calculate";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
//
// checkBox1
//
this->checkBox1->AutoSize = true;
this->checkBox1->Location = System::Drawing::Point(18, 203);
this->checkBox1->Margin = System::Windows::Forms::Padding(4);
this->checkBox1->Name = L"checkBox1";
this->checkBox1->Size = System::Drawing::Size(220, 23);
this->checkBox1->TabIndex = 1;
this->checkBox1->Text = L"Government Tax Reduction\?";
this->checkBox1->UseVisualStyleBackColor = true;
this->checkBox1->CheckedChanged += gcnew System::EventHandler(this, &Form1::checkBox1_CheckedChanged);
//
// button2
//
this->button2->Location = System::Drawing::Point(22, 269);
this->button2->Margin = System::Windows::Forms::Padding(4);
this->button2->Name = L"button2";
this->button2->Size = System::Drawing::Size(254, 86);
this->button2->TabIndex = 2;
this->button2->Text = L"Reset";
this->button2->UseVisualStyleBackColor = true;
//
// textBox1
//
this->textBox1->Location = System::Drawing::Point(22, 42);
this->textBox1->Margin = System::Windows::Forms::Padding(4);
this->textBox1->Name = L"textBox1";
this->textBox1->Size = System::Drawing::Size(238, 26);
this->textBox1->TabIndex = 3;
this->textBox1->TextChanged += gcnew System::EventHandler(this, &Form1::textBox1_TextChanged);
//
// label1
//
this->label1->AutoSize = true;
this->label1->Location = System::Drawing::Point(18, 19);
this->label1->Margin = System::Windows::Forms::Padding(4, 0, 4, 0);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(103, 19);
this->label1->TabIndex = 4;
this->label1->Text = L"Market Value";
//
// label2
//
this->label2->AutoSize = true;
this->label2->Location = System::Drawing::Point(18, 76);
this->label2->Margin = System::Windows::Forms::Padding(4, 0, 4, 0);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(123, 19);
this->label2->TabIndex = 5;
this->label2->Text = L"Number Of Mills";
//
// textBox2
//
this->textBox2->Location = System::Drawing::Point(22, 99);
this->textBox2->Margin = System::Windows::Forms::Padding(4);
this->textBox2->Name = L"textBox2";
this->textBox2->Size = System::Drawing::Size(238, 26);
this->textBox2->TabIndex = 6;
//
// label3
//
this->label3->AutoSize = true;
this->label3->Font = (gcnew System::Drawing::Font(L"Times New Roman", 18, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label3->Location = System::Drawing::Point(346, 9);
this->label3->Margin = System::Windows::Forms::Padding(4, 0, 4, 0);
this->label3->Name = L"label3";
this->label3->Size = System::Drawing::Size(177, 26);
this->label3->TabIndex = 7;
this->label3->Text = L"Your Taxes Cost";
this->label3->Click += gcnew System::EventHandler(this, &Form1::label3_Click);
//
// textBox3
//
this->textBox3->Location = System::Drawing::Point(318, 66);
this->textBox3->Margin = System::Windows::Forms::Padding(4);
this->textBox3->Name = L"textBox3";
this->textBox3->Size = System::Drawing::Size(238, 26);
this->textBox3->TabIndex = 8;
//
// label4
//
this->label4->AutoSize = true;
this->label4->Location = System::Drawing::Point(314, 42);
this->label4->Margin = System::Windows::Forms::Padding(4, 0, 4, 0);
this->label4->Name = L"label4";
this->label4->Size = System::Drawing::Size(65, 19);
this->label4->TabIndex = 9;
this->label4->Text = L"Per Year";
//
// label5
//
this->label5->AutoSize = true;
this->label5->Location = System::Drawing::Point(314, 110);
this->label5->Margin = System::Windows::Forms::Padding(4, 0, 4, 0);
this->label5->Name = L"label5";
this->label5->Size = System::Drawing::Size(81, 19);
this->label5->TabIndex = 10;
this->label5->Text = L"Per Month";
//
// textBox4
//
this->textBox4->Location = System::Drawing::Point(318, 133);
this->textBox4->Margin = System::Windows::Forms::Padding(4);
this->textBox4->Name = L"textBox4";
this->textBox4->Size = System::Drawing::Size(238, 26);
this->textBox4->TabIndex = 11;
//
// textBox5
//
this->textBox5->BackColor = System::Drawing::SystemColors::Info;
this->textBox5->Location = System::Drawing::Point(580, 9);
this->textBox5->Margin = System::Windows::Forms::Padding(4);
this->textBox5->Multiline = true;
this->textBox5->Name = L"textBox5";
this->textBox5->Size = System::Drawing::Size(222, 346);
this->textBox5->TabIndex = 12;
this->textBox5->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
this->textBox5->TextChanged += gcnew System::EventHandler(this, &Form1::textBox5_TextChanged);
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(9, 19);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->BackColor = System::Drawing::SystemColors::AppWorkspace;
this->BackgroundImage = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"$this.BackgroundImage")));
this->BackgroundImageLayout = System::Windows::Forms::ImageLayout::Stretch;
this->ClientSize = System::Drawing::Size(808, 371);
this->Controls->Add(this->textBox5);
this->Controls->Add(this->textBox4);
this->Controls->Add(this->label5);
this->Controls->Add(this->label4);
this->Controls->Add(this->textBox3);
this->Controls->Add(this->label3);
this->Controls->Add(this->textBox2);
this->Controls->Add(this->label2);
this->Controls->Add(this->label1);
this->Controls->Add(this->textBox1);
this->Controls->Add(this->button2);
this->Controls->Add(this->checkBox1);
this->Controls->Add(this->button1);
this->Font = (gcnew System::Drawing::Font(L"Times New Roman", 12, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::Fixed3D;
this->Margin = System::Windows::Forms::Padding(4);
this->Name = L"Form1";
this->Text = L"School Levy Calculator";
this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
this->ResumeLayout(false);
this->PerformLayout();

}
#pragma endregion
private: System::Void checkBox1_CheckedChanged(System::Object^ sender, System::EventArgs^ e) {
if (checkBox1 = 1){ cout << "Your proporty taxes cost for " << nZ << " mill(s) is {:content:}quot; << nMillCalc * nX * .875 << " per year or {:content:}quot; << ((nMillCalc * nX * .875) / 12) << " per month " << endl;
}
}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void textBox1_TextChanged(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void label3_Click(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void textBox5_TextChanged(System::Object^ sender, System::EventArgs^ e) {
}
};
}

[/code]

Share this post


Link to post
Share on other sites
If you're going to use windows forms in your C++ app. then you should realize that you are getting into the world of C++/CLI which can be a pain to work with. Personally I wouldn't advise going that route since it can be very confusing when you starting having to dealing with code that handles native functionality and interacts with .NET. If you are determined to get it working in a window I would go with one of the suggestions oler1s listed.

edit: didn't see the second page.

To port your code into the form most of your work is going to be in the event handlers you created for the text boxes and buttons. The TextChanged events will be where you assign values to variables and the Click events will be where you put in your calculations or reset the values in the text boxes.

Share this post


Link to post
Share on other sites

This topic is 2392 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this