Welcome Back Guys,
For this you have to continue my previous Tutorial, if you have missed it then just take a look on it.
This Whole Tutorial is available as "Video" at the Button of this page .
Starting at First. Open that Form and to to this tab.
1. Go to this "MyForm.h [Design]".
2. Then From "View" Select "Toolbox".
3. Then From Toolbox Select "Label"
4. Just Drag and drop that label to the form.
Align your label where ever you want :) . Now Moving to Buttons so we can perform a function on our label.
6. Now Select Button in the Toolbox , drag and drop it to the form as we done with label.
7.Double Click on Button and you will get a Coding screen where you can specify your functions. lets do it
Some Important points.
Windows Form uses a string called System::String its different from std::string. So if you have to take some text from labels or Buttons or Text boxes and have to use it the c++ code then you have to convert System::String to std::string. we will discuss about the conversion later on.
Windows Form uses a string called System::String its different from std::string. So if you have to take some text from labels or Buttons or Text boxes and have to use it the c++ code then you have to convert System::String to std::string. we will discuss about the conversion later on.
8. Now take a look on this code(Most important part of the Program) : Fibonacci Series
- We had declared the variables outside of the function because if we had declared inside the function then it automatically initializes to null because we have to call the function again and again.So declaring the variables outside would not kill the values of the variables by clicking the button.
here Clicking the button = Calling the function
- String ^ Show is a String variable used by the Windows Form for Text purposes its different from string Show ( ^ this sign is Pointer) .
String ^ Show = System::Convert::ToString(sum);
this line is a conversion of Integer to System::String because anything displayed on Form must be in String.
label1->Text is the Object's Attribute we can set it according to our self.
here label1->Text will have value = Show which contains the sum of the numbers.
9. Now Simply Write that Code in your Project as I've done and click on "Local Windows Debugger" then click your button and Hallelujah!


Tutorial Video.
Acha hai😎😎 keep it up!
ReplyDelete