Submit Search
Upload
Notes how to work with variables, constants and do calculations
ā¢
0 likes
ā¢
135 views
William Olivier
Follow
Visual C++ Programming Concepts
Read less
Read more
Software
Report
Share
Report
Share
1 of 4
Download now
Download to read offline
Recommended
INTRODUCTION TO C
INTRODUCTION TO C
Damith Shan Abeywickrema
Ā
Lab3cth
Lab3cth
Muhammad Yusfa
Ā
Chapter2
Chapter2
Anees999
Ā
Visual Basic Programming
Visual Basic Programming
Osama Yaseen
Ā
Solutions manual for c++ programming from problem analysis to program design ...
Solutions manual for c++ programming from problem analysis to program design ...
Warren0989
Ā
Chapter 4 5
Chapter 4 5
ahmed22dg
Ā
Duplicate Code Detection using Control Statements
Duplicate Code Detection using Control Statements
Editor IJCATR
Ā
Vb introduction.
Vb introduction.
sagaroceanic11
Ā
Recommended
INTRODUCTION TO C
INTRODUCTION TO C
Damith Shan Abeywickrema
Ā
Lab3cth
Lab3cth
Muhammad Yusfa
Ā
Chapter2
Chapter2
Anees999
Ā
Visual Basic Programming
Visual Basic Programming
Osama Yaseen
Ā
Solutions manual for c++ programming from problem analysis to program design ...
Solutions manual for c++ programming from problem analysis to program design ...
Warren0989
Ā
Chapter 4 5
Chapter 4 5
ahmed22dg
Ā
Duplicate Code Detection using Control Statements
Duplicate Code Detection using Control Statements
Editor IJCATR
Ā
Vb introduction.
Vb introduction.
sagaroceanic11
Ā
Book management system
Book management system
SHARDA SHARAN
Ā
Chapter 05
Chapter 05
llmeade
Ā
Literals,variables,datatype in C#
Literals,variables,datatype in C#
Prasanna Kumar SM
Ā
Chapter 3 ā Program Design and Coding
Chapter 3 ā Program Design and Coding
francopw
Ā
Fundamentals of Programming Chapter 4
Fundamentals of Programming Chapter 4
Mohd Harris Ahmad Jaal
Ā
Visual Basics for Application
Visual Basics for Application
Raghu nath
Ā
Chapter 4 ā Variables and Arithmetic Operations
Chapter 4 ā Variables and Arithmetic Operations
francopw
Ā
Operators and Expressions in C#
Operators and Expressions in C#
Prasanna Kumar SM
Ā
Introduction to visual basic 6 (1)
Introduction to visual basic 6 (1)
Mark Vincent Cantero
Ā
Chapter 04
Chapter 04
llmeade
Ā
Intake 38 4
Intake 38 4
Mahmoud Ouf
Ā
Csharp
Csharp
vinayabburi
Ā
Visual Logic Project - 1
Visual Logic Project - 1
Programming Techniques and Algorithms
Ā
Core C# Programming Constructs, Part 1
Core C# Programming Constructs, Part 1
Vahid Farahmandian
Ā
Chapter 08
Chapter 08
llmeade
Ā
Vba
Vba
Juhi Mahajan
Ā
Excel chapter-7
Excel chapter-7
OpenCastLabs Consulting
Ā
Excel y visual basic
Excel y visual basic
Egidio Mosquer Copete
Ā
TechnikwĆ¼rze - Vorstellung und HintergrĆ¼nde zum Podcast fĆ¼r Webentwickler
TechnikwĆ¼rze - Vorstellung und HintergrĆ¼nde zum Podcast fĆ¼r Webentwickler
David Maciejewski
Ā
Š¾ŃŠ½Š¾Š²Š½ŃŠµ Š½Š°ŠæŃŠ°Š²Š»ŠµŠ½ŠøŃ_Š¼ŠµŃŠ¾Š“._ŃŠ°Š±Š¾ŃŃ_2015-2016_ŠµŃŃŃŃŠ¾_
Š¾ŃŠ½Š¾Š²Š½ŃŠµ Š½Š°ŠæŃŠ°Š²Š»ŠµŠ½ŠøŃ_Š¼ŠµŃŠ¾Š“._ŃŠ°Š±Š¾ŃŃ_2015-2016_ŠµŃŃŃŃŠ¾_
vikaevp
Ā
Ćfrica
Ćfrica
trixi nicolas
Ā
Transparent Object Proxies for JavaScript
Transparent Object Proxies for JavaScript
Matthias Keil
Ā
More Related Content
What's hot
Book management system
Book management system
SHARDA SHARAN
Ā
Chapter 05
Chapter 05
llmeade
Ā
Literals,variables,datatype in C#
Literals,variables,datatype in C#
Prasanna Kumar SM
Ā
Chapter 3 ā Program Design and Coding
Chapter 3 ā Program Design and Coding
francopw
Ā
Fundamentals of Programming Chapter 4
Fundamentals of Programming Chapter 4
Mohd Harris Ahmad Jaal
Ā
Visual Basics for Application
Visual Basics for Application
Raghu nath
Ā
Chapter 4 ā Variables and Arithmetic Operations
Chapter 4 ā Variables and Arithmetic Operations
francopw
Ā
Operators and Expressions in C#
Operators and Expressions in C#
Prasanna Kumar SM
Ā
Introduction to visual basic 6 (1)
Introduction to visual basic 6 (1)
Mark Vincent Cantero
Ā
Chapter 04
Chapter 04
llmeade
Ā
Intake 38 4
Intake 38 4
Mahmoud Ouf
Ā
Csharp
Csharp
vinayabburi
Ā
Visual Logic Project - 1
Visual Logic Project - 1
Programming Techniques and Algorithms
Ā
Core C# Programming Constructs, Part 1
Core C# Programming Constructs, Part 1
Vahid Farahmandian
Ā
Chapter 08
Chapter 08
llmeade
Ā
What's hot
(15)
Book management system
Book management system
Ā
Chapter 05
Chapter 05
Ā
Literals,variables,datatype in C#
Literals,variables,datatype in C#
Ā
Chapter 3 ā Program Design and Coding
Chapter 3 ā Program Design and Coding
Ā
Fundamentals of Programming Chapter 4
Fundamentals of Programming Chapter 4
Ā
Visual Basics for Application
Visual Basics for Application
Ā
Chapter 4 ā Variables and Arithmetic Operations
Chapter 4 ā Variables and Arithmetic Operations
Ā
Operators and Expressions in C#
Operators and Expressions in C#
Ā
Introduction to visual basic 6 (1)
Introduction to visual basic 6 (1)
Ā
Chapter 04
Chapter 04
Ā
Intake 38 4
Intake 38 4
Ā
Csharp
Csharp
Ā
Visual Logic Project - 1
Visual Logic Project - 1
Ā
Core C# Programming Constructs, Part 1
Core C# Programming Constructs, Part 1
Ā
Chapter 08
Chapter 08
Ā
Viewers also liked
Vba
Vba
Juhi Mahajan
Ā
Excel chapter-7
Excel chapter-7
OpenCastLabs Consulting
Ā
Excel y visual basic
Excel y visual basic
Egidio Mosquer Copete
Ā
TechnikwĆ¼rze - Vorstellung und HintergrĆ¼nde zum Podcast fĆ¼r Webentwickler
TechnikwĆ¼rze - Vorstellung und HintergrĆ¼nde zum Podcast fĆ¼r Webentwickler
David Maciejewski
Ā
Š¾ŃŠ½Š¾Š²Š½ŃŠµ Š½Š°ŠæŃŠ°Š²Š»ŠµŠ½ŠøŃ_Š¼ŠµŃŠ¾Š“._ŃŠ°Š±Š¾ŃŃ_2015-2016_ŠµŃŃŃŃŠ¾_
Š¾ŃŠ½Š¾Š²Š½ŃŠµ Š½Š°ŠæŃŠ°Š²Š»ŠµŠ½ŠøŃ_Š¼ŠµŃŠ¾Š“._ŃŠ°Š±Š¾ŃŃ_2015-2016_ŠµŃŃŃŃŠ¾_
vikaevp
Ā
Ćfrica
Ćfrica
trixi nicolas
Ā
Transparent Object Proxies for JavaScript
Transparent Object Proxies for JavaScript
Matthias Keil
Ā
Dna sequencing
Dna sequencing
Neeraj Sharma
Ā
MentalHealthParity
MentalHealthParity
Tim Rozelle
Ā
Desarrollo sostenible
Desarrollo sostenible
Mariaezquivel
Ā
Viber katarzyna koÅodziej
Viber katarzyna koÅodziej
kasiczek23
Ā
Spelling
Spelling
Jelena Majkic
Ā
Research methods
Research methods
Arfan rai
Ā
Europa
Europa
trixi nicolas
Ā
Icelandic-Fish-and-Seafood-Catalogue_English (1)
Icelandic-Fish-and-Seafood-Catalogue_English (1)
Thuc To
Ā
key concepts of marketing 1
key concepts of marketing 1
Neeraj Sharma
Ā
Programming inexcelvba anintroduction
Programming inexcelvba anintroduction
Ofun Emma
Ā
Baisse de concentration suite Ć interruption
Baisse de concentration suite Ć interruption
aproposdelles
Ā
E learning excel vba programming lesson 1
E learning excel vba programming lesson 1
Vijay Perepa
Ā
Intro macros in Excel 2007
Intro macros in Excel 2007
Hasrudin Tazep
Ā
Viewers also liked
(20)
Vba
Vba
Ā
Excel chapter-7
Excel chapter-7
Ā
Excel y visual basic
Excel y visual basic
Ā
TechnikwĆ¼rze - Vorstellung und HintergrĆ¼nde zum Podcast fĆ¼r Webentwickler
TechnikwĆ¼rze - Vorstellung und HintergrĆ¼nde zum Podcast fĆ¼r Webentwickler
Ā
Š¾ŃŠ½Š¾Š²Š½ŃŠµ Š½Š°ŠæŃŠ°Š²Š»ŠµŠ½ŠøŃ_Š¼ŠµŃŠ¾Š“._ŃŠ°Š±Š¾ŃŃ_2015-2016_ŠµŃŃŃŃŠ¾_
Š¾ŃŠ½Š¾Š²Š½ŃŠµ Š½Š°ŠæŃŠ°Š²Š»ŠµŠ½ŠøŃ_Š¼ŠµŃŠ¾Š“._ŃŠ°Š±Š¾ŃŃ_2015-2016_ŠµŃŃŃŃŠ¾_
Ā
Ćfrica
Ćfrica
Ā
Transparent Object Proxies for JavaScript
Transparent Object Proxies for JavaScript
Ā
Dna sequencing
Dna sequencing
Ā
MentalHealthParity
MentalHealthParity
Ā
Desarrollo sostenible
Desarrollo sostenible
Ā
Viber katarzyna koÅodziej
Viber katarzyna koÅodziej
Ā
Spelling
Spelling
Ā
Research methods
Research methods
Ā
Europa
Europa
Ā
Icelandic-Fish-and-Seafood-Catalogue_English (1)
Icelandic-Fish-and-Seafood-Catalogue_English (1)
Ā
key concepts of marketing 1
key concepts of marketing 1
Ā
Programming inexcelvba anintroduction
Programming inexcelvba anintroduction
Ā
Baisse de concentration suite Ć interruption
Baisse de concentration suite Ć interruption
Ā
E learning excel vba programming lesson 1
E learning excel vba programming lesson 1
Ā
Intro macros in Excel 2007
Intro macros in Excel 2007
Ā
Similar to Notes how to work with variables, constants and do calculations
PRELIM-Lesson-2.pdf
PRELIM-Lesson-2.pdf
jaymaraltamera
Ā
Introduction to Visual Basic
Introduction to Visual Basic
Amity University | FMS - DU | IMT | Stratford University | KKMI International Institute | AIMA | DTU
Ā
Contact management system
Contact management system
SHARDA SHARAN
Ā
Introduction to Programming Fundamentals 3.pdf
Introduction to Programming Fundamentals 3.pdf
AbrehamKassa
Ā
Program logic and design
Program logic and design
Chaffey College
Ā
Understanding Code Formats in Vista
Understanding Code Formats in Vista
Visibility by Design
Ā
Programming concepts By ZAK
Programming concepts By ZAK
Tabsheer Hasan
Ā
Chapter 2- Prog101.ppt
Chapter 2- Prog101.ppt
JosephObadiahTuray
Ā
C programming session 09
C programming session 09
Dushmanta Nath
Ā
Problem Solving Techniques
Problem Solving Techniques
Ashesh R
Ā
C Programming Unit-1
C Programming Unit-1
Vikram Nandini
Ā
c#.pptx
c#.pptx
JoselitoJMebolos
Ā
Visual Basic Review - ICA
Visual Basic Review - ICA
emtrajano
Ā
ADBMS ASSIGNMENT
ADBMS ASSIGNMENT
Lori Moore
Ā
Introduction to Procedural Programming in C++
Introduction to Procedural Programming in C++
Salahaddin University-Erbil
Ā
COM 211 PRESENTATION.pptx
COM 211 PRESENTATION.pptx
AnasYunusa
Ā
Vb6.0 intro
Vb6.0 intro
JOSEPHINEA6
Ā
Ms vb
Ms vb
sirjade4
Ā
Introduction to āCā Language
Introduction to āCā Language
Thesis Scientist Private Limited
Ā
Naveen Kumar Bokku
Naveen Kumar Bokku
Naveen Bokku
Ā
Similar to Notes how to work with variables, constants and do calculations
(20)
PRELIM-Lesson-2.pdf
PRELIM-Lesson-2.pdf
Ā
Introduction to Visual Basic
Introduction to Visual Basic
Ā
Contact management system
Contact management system
Ā
Introduction to Programming Fundamentals 3.pdf
Introduction to Programming Fundamentals 3.pdf
Ā
Program logic and design
Program logic and design
Ā
Understanding Code Formats in Vista
Understanding Code Formats in Vista
Ā
Programming concepts By ZAK
Programming concepts By ZAK
Ā
Chapter 2- Prog101.ppt
Chapter 2- Prog101.ppt
Ā
C programming session 09
C programming session 09
Ā
Problem Solving Techniques
Problem Solving Techniques
Ā
C Programming Unit-1
C Programming Unit-1
Ā
c#.pptx
c#.pptx
Ā
Visual Basic Review - ICA
Visual Basic Review - ICA
Ā
ADBMS ASSIGNMENT
ADBMS ASSIGNMENT
Ā
Introduction to Procedural Programming in C++
Introduction to Procedural Programming in C++
Ā
COM 211 PRESENTATION.pptx
COM 211 PRESENTATION.pptx
Ā
Vb6.0 intro
Vb6.0 intro
Ā
Ms vb
Ms vb
Ā
Introduction to āCā Language
Introduction to āCā Language
Ā
Naveen Kumar Bokku
Naveen Kumar Bokku
Ā
Recently uploaded
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
AmarnathKambale
Ā
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
masabamasaba
Ā
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
Ā
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
masabamasaba
Ā
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
masabamasaba
Ā
Software Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
Arshad QA
Ā
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
harshavardhanraghave
Ā
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
SelfMade bd
Ā
Define the academic and professional writing..pdf
Define the academic and professional writing..pdf
PearlKirahMaeRagusta1
Ā
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
kalichargn70th171
Ā
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
proinshot.com
Ā
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
Willy Marroquin (WillyDevNET)
Ā
call girls in Vaishali (Ghaziabad) š >ą¼8448380779 š genuine Escort Service šāļøāļø
call girls in Vaishali (Ghaziabad) š >ą¼8448380779 š genuine Escort Service šāļøāļø
Delhi Call girls
Ā
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
Ā
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
ayushiqss
Ā
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
panagenda
Ā
The title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
Ā
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
Shane Coughlan
Ā
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
Ā
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
Papp KrisztiƔn
Ā
Recently uploaded
(20)
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
Ā
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
Ā
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
Ā
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
Ā
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
Ā
Software Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
Ā
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Ā
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Ā
Define the academic and professional writing..pdf
Define the academic and professional writing..pdf
Ā
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Ā
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
Ā
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
Ā
call girls in Vaishali (Ghaziabad) š >ą¼8448380779 š genuine Escort Service šāļøāļø
call girls in Vaishali (Ghaziabad) š >ą¼8448380779 š genuine Escort Service šāļøāļø
Ā
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
Ā
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
Ā
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
Ā
The title is not connected to what is inside
The title is not connected to what is inside
Ā
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
Ā
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
Ā
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
Ā
Notes how to work with variables, constants and do calculations
1.
Development Software 2
ā DOS200S Compiled By WH. Olivier Ā©2013 Cape Peninsula University of Technology Window Form Applications Using Visual C++ Variables, Constants and Calculations Objectives and Learning Areas: For this lesson you will learn how to do the follow: 1. Knowing the different data types 2. How to define constant and variable identifiers 3. The scope of identifiers and where to declare identifiers 4. How to convert data from one type to another. Introduction For any program that you will be developing in Visual C++, or any other computer language for that matter, has three fundamental components to it. It is: INPUT: what will be the input values that will be fed into the program by the user? PROCESS: what are the operations to be performed by the program? OUTPUT: what are the results that will be produced by the program as feedback to the user? When designing an application program, the requirements for the application would state what the Inputs are, what process must be performed on the input data, and what would be the output produced. The components explained above are shown with the use of an application. Storing and retrieving data Data in the application above is stored in the Text property of the textBox object (control) on screen. For every application that you develop, there must be a way to store and retrieve data. There are various ways in which to store data and this is dependent on how you would want to use the data in the application. Here some way: 1. Constants. These are data types that are declared with a set value and cannot be changed throughout the running of the application. A good example would be the number of months or number of days in a week. const int WEEKDAYS = 7; INPUTS PROCESS OUTPUT INPUTS
2.
Development Software 2
ā DOS200S Compiled By WH. Olivier Ā©2013 Cape Peninsula University of Technology 2. Variables. These identifiers are there to store data that are expected to change throughout the program. When the user inputs different values, a calculation will produce different results for each input. Variables in this case are best suited. An example would be a different price for a different item record. double itemPrice; 3. Arrays. When you want to store a list or collection of related information, you can declare and array and store the collection in it. Each individual item can them be reference via an index and using the same identifier name. An example would be if you want to store a list of names or test scores. int testScores[5]; 4. Structures. This identifier is a user-defined data type which comprises of other data types and is designed to suite the programmer needs. With this identifier, related variables are grouped into a single variable where by each individual data member will be referenced using a access operator. An example would be related student information like student number, name, subjects and scores. struct StudDetail { int studNum; string name; string subjects[5]; }; Data Types and Usage The table below shows the various data types that can be used in Visual C++. Also indicated are the managed and unmanaged uses. C++ Data Type Common Language Runtime (CLR) Data Types (managed) Primitive data types (unmanaged) Use For Storage Size in Bytes Sample data Boolean Boolean bool True or False values 2 flag Byte Byte - 0 ā 255, binary data 1 singleNumber Char - char Single Unicode character 2 Gender (M/F) Date DateTime 1/1/0001 ā 12/31/9999 8 currentDate Decimal Decimal float Decimal fractions 16 Rand Double Double double Double-precision floating- point numbers 8 PI Single Single Single-precision floating- point numbers 4 Length Short Int16 short Small integers 2 Age Integer Int32 int Whole numbers 4 NumGoals Long Int64 long Large whole numbers 8 IDnumber String String^ string Alphanumeric data (characters) Varies Name Object Object (class / struct) Any type of data 4
3.
Development Software 2
ā DOS200S Compiled By WH. Olivier Ā©2013 Cape Peninsula University of Technology Data declarations and scope of identifiers Depending on where you declare an identifier, it can either be local or global. This means that if a variable is declared within a function or procedure, it is local to that procedure or function. If, however, you would want that identifier to be global, you would declare it outside of any function block. Letās look at the following example to illustrate local and global identifiers. A windows form application calculates the gross salary by adding the basic salary to the bonus amounts. The calculation is done on the press of a button. Local Variable Declarations private: System::Void btnCalc_Click(System::Object^ sender, System::EventArgs^ e) { double basic = 0; double bonus = 0; basic = Double::Parse(txtBSalary->Text); bonus = Double::Parse(txtBonus->Text); double salary = basic + bonus; txtGSalary->Text = "R " + salary.ToString("F"); } Local variables can only be used within the function or procedure where it is declared in. This relates to the scope of the identifier. Global Variable Declarations Global identifiers are not declared in any function or procedure. Their scope is global and therefore can be used in any other function within the current form. There are two places in the code editor where global variables can be declared. The first area is in the āRequired designer variableā section. As shown below, it is just before the area where code for all the controls on screen are generated. /// <summary> /// Required designer variable. /// </summary> Int32 intClickCounter; Int32 intTimerCounter; DateTime myTime; #pragma region Windows Form Designer generated code As the comment indicates, you can only declare variables in this area. Here you can use any data type which suites the requirements. The second area is just before the class definition of the current form as shown here below. /// <summary> /// Summary for Form1 /// </summary> int globalNumber = 0; public ref class Form1 : public System::Windows::Forms::Form {... Global variable declared in the āRequire designer variableā section cannot be initialized there. The best place to initialize these variables is when the form is loaded as shown below. private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) { intClickCounter = 0; intTimerCounter = 30; } Local Variable declarations. The variables are initialized to 0 Conversion from String to double. The values on in the Text property of the textbox control is converted to double and assigned to the double variables Global Variable declarations. These variables are declared in the āRequired designer variableā section. Global Variable declarations. Declared just before the Form1 class definition. It is also initialized here. Global Variables Initialized. Variables are initialized to 0 and 30 respectably.
4.
Development Software 2
ā DOS200S Compiled By WH. Olivier Ā©2013 Cape Peninsula University of Technology Constant declarations Constants can either be global or local. When they are declared locally, they are declared with in a procedure or function. There are two ways in which to define constants. - Using the const reserve word. - - Using the #define preprocessor #pragma once const int MONTHS = 12; #define LENGTH 10 #define WIDTH 5 namespace SalaryCalc1 {... Take note of where constants are being declared above. These are declared as global constants. Converting values from one data type to another. When working with values where by the user must enter data in a textbox and that data must be used in some calculation, these values must be converted to an equivalent type which would allow the calculation to be done. Consider the following screen layout of Salary Calculation Application; In this example the user is requested to enter the Basic Salary and Bonus amounts. On pressing the āCalculate Salaryā button, the application will take the values in the textboxes as entered by the user and use that in a calculation to produce the āGross Salaryā. Note that values entered in on screen are all regarded as Strings and can therefore not be used within a calculation. For this reason, these values must first be converted to an appropriate format which would allow the calculation to be done. Here is the code that would accomplish this. private: System::Void btnCalc_Click(System::Object^ sender, System::EventArgs^ e) { double basic = Double::Parse(txtBSalary->Text); double bonus = Double::Parse(txtBonus->Text); double salary = basic + bonus; txtGSalary->Text = "R " + salary.ToString("F"); } Constant named MOUNT defined using const reserve word Constants named LENGTH and WIDTH defined using #define preprocessor. Converting from String to double Converting from double to String
Download now