I don't understand why you need it.
It's an event handler for keypresses for a textbox that is not on your form.
If you tell me what your program is supposed to do, I will suggest how to do it.

Since there is no numeric box, I have to insert numbers in the textbox.
I want to write a program for solving simple mathematical operations such as Quadratic equation. See the link below.
http://en.wikipedia.org/wiki/Quadratic_equation
My problem is I need putting only numbers (with decimals) in textboxes.
Thats why I want to change the textbox into a numeric box,
so it does not accept letters, only numbers.

OK. If you don't actually need to write the code yourself, I suggest downloading the DLL on code project for the Simple Numeric Textbox and add that to your app.

Add a reference to the downloaded DLL.
add: using namespace CodeProject:: DaveyM69::WinForms::Controls; to the top or your Form1.h
...without the extra space.

// Change the
private: System::Windows::Forms::TextBox^  A;
// to
private: NumericTextBox^  A;
//and change the InitializeComponent function from
void InitializeComponent(void)
{
   this->A = (gcnew System::Windows::Forms::TextBox());
// ...

/* to */

void InitializeComponent(void)
{
   this->A = (gcnew NumericTextBox());
//...

I am sorry to disturb you again, my english is not very good.
I probably didn't mention it clearly that I needed a solution in C++, not C#
and not a readymade program, but a cue to help me write the program myself, because I am studiing C++, and this is a homework. Furthermore I need decimal point (comma, becuse in my country we use decimal comma instead of decimal point). I also need the "minus" character to be accepted by this box. I have found a code, but I can't insert it into my program. The code is the following:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
 
namespace MyControls
{
    class NumericTextBox : TextBox
    {
        protected override void OnKeyPress(KeyPressEventArgs e)
        {
            base.OnKeyPress(e);
            // Check if the pressed character was a backspace or numeric.
            if (e.KeyChar != (char)8  && !char.IsNumber(e.KeyChar))
            {
                e.Handled = true;
            }
        }
    }
}

I think it will work with the necessary changes.
Can you give me advice how to insert this code in my program?

The techniques used will translate easily to C++.
If you can't use the DLL, then read the code and do what that developer is doing.
You can use the techniques from that page to make your app work and if you need to add floating point numbers, do that too.

[Previous examples]
I explained earlier how to attach the C++ code you found and posted (earlier).

This is where you need to study the techniques and make adjustments to your own code.

What's the problem of this code?

private: System::Void A_TextChanged(System::Object^  sender, System::EventArgs^  e) {
	 int found = 0;
	 found = A -> IndexOf( "," );
         A -> Text = A -> Substring( found );
 }

d:\c++\masodfokuform\masodfokuform\Form1.h(297): error C2039: 'IndexOf' : is not a member of 'System::Windows::Forms::TextBox'
c:\program files\reference assemblies\microsoft\framework\.netframework\v4.0\system.windows.forms.dll : see declaration of 'System::Windows::Forms::TextBox'
d:\c++\masodfokuform\masodfokuform\Form1.h(298): error C2039: 'Substring' : is not a member of 'System::Windows::Forms::TextBox'
c:\program files\reference assemblies\microsoft\framework\.netframework\v4.0\system.windows.forms.dll : see declaration of 'System::Windows::Forms::TextBox'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

How about:

A->Text->IndexOf(",");

Sorry to disturb you again, my english is not enugh to understand msdn help, so I always stops somewere. Next thing I would like to do is change "," to "." during typing. I have tried it put I can't. The mistake is usage of concat method. How can I put it correctly?

private: System::Void A_TextChanged(System::Object^  sender, System::EventArgs^  e) {
int found = 0;
 found = A -> Text ->IndexOf( "," );
 if(found>0)
 A -> Text = concat(A -> Text -> Remove(found,1),"."); }

Also I want to put cursor position after the last character I have typed.

You can use the same keystroke event trap to deny the period and allow the comma.
You could also use ->Text->Replace(".", ",") to convert them.
Use the Select method on the text box to set the cursor position.

What is the difference betwwwn . :: and -> operators.
A good link which explain that would be accepted.

Scope Resolution Operator ::
the :: represents something that is static inside a class (won't be instantiated; just used)

It can also represent objects that are available at the module-level when used with no leading decoration.

and the arrow -> represents a pointer to a member or managed member.


[references]
http://www.daniweb.com/software-development/cpp/threads/36037
http://en.wikipedia.org/wiki/Scope_resolution_operator
http://msdn.microsoft.com/en-us/library/b451xz31(VS.80).aspx

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.