Форум программистов, компьютерный форум, киберфорум
C++/CLI Windows Forms
Войти
Регистрация
Восстановить пароль
Карта форума Темы раздела Блоги Сообщество Поиск Заказать работу  
 
Рейтинг 4.62/13: Рейтинг темы: голосов - 13, средняя оценка - 4.62
0 / 0 / 0
Регистрация: 12.02.2013
Сообщений: 21
1

Как проверить что в textBox введен какой-то символ? Есть для этого какое-то событие?

31.05.2013, 11:14. Показов 2688. Ответов 7
Метки нет (Все метки)

Author24 — интернет-сервис помощи студентам
Windows Forms. Пишу простой калькулятор.
вот код Файлa Form.h
C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
#pragma once
namespace Калькулятор {
 
    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>
    /// Сводка для Form1
    /// </summary>
    public ref class Form1 : public System::Windows::Forms::Form
    {
    public:
        Form1(void)
        {
            InitializeComponent();
            //
            //TODO: добавьте код конструктора
            //
        }
 
    protected:
        /// <summary>
        /// Освободить все используемые ресурсы.
        /// </summary>
        ~Form1()
        {
            if (components)
            {
                delete components;
            }
        }
 
 
    protected: 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
    private: System::Windows::Forms::TextBox^  textBox1;
    private: System::Windows::Forms::Button^  button1;
    private: System::Windows::Forms::Button^  button2;
    private: System::Windows::Forms::Button^  button3;
    private: System::Windows::Forms::Button^  button4;
    private: System::Windows::Forms::Button^  button5;
    private: System::Windows::Forms::Button^  button6;
    private: System::Windows::Forms::Button^  button7;
    private: System::Windows::Forms::Button^  button8;
    private: System::Windows::Forms::Button^  button9;
    private: System::Windows::Forms::Button^  button10;
    private: System::Windows::Forms::Button^  button11;
    private: System::Windows::Forms::Button^  button12;
    private: System::Windows::Forms::Button^  button13;
    private: System::Windows::Forms::Button^  button14;
    private: System::Windows::Forms::Button^  button15;
    private: System::Windows::Forms::Button^  button16;
    private: System::Windows::Forms::Button^  button17;
 
    protected: 
 
    private:
        /// <summary>
        /// Требуется переменная конструктора.
        /// </summary>
        System::ComponentModel::Container ^components;
 
#pragma region Windows Form Designer generated code
        /// <summary>
        /// Обязательный метод для поддержки конструктора - не изменяйте
        /// содержимое данного метода при помощи редактора кода.
        /// </summary>
        void InitializeComponent(void)
        {
            this->textBox1 = (gcnew System::Windows::Forms::TextBox());
            this->button1 = (gcnew System::Windows::Forms::Button());
            this->button2 = (gcnew System::Windows::Forms::Button());
            this->button3 = (gcnew System::Windows::Forms::Button());
            this->button4 = (gcnew System::Windows::Forms::Button());
            this->button5 = (gcnew System::Windows::Forms::Button());
            this->button6 = (gcnew System::Windows::Forms::Button());
            this->button7 = (gcnew System::Windows::Forms::Button());
            this->button8 = (gcnew System::Windows::Forms::Button());
            this->button9 = (gcnew System::Windows::Forms::Button());
            this->button10 = (gcnew System::Windows::Forms::Button());
            this->button11 = (gcnew System::Windows::Forms::Button());
            this->button12 = (gcnew System::Windows::Forms::Button());
            this->button13 = (gcnew System::Windows::Forms::Button());
            this->button14 = (gcnew System::Windows::Forms::Button());
            this->button15 = (gcnew System::Windows::Forms::Button());
            this->button16 = (gcnew System::Windows::Forms::Button());
            this->button17 = (gcnew System::Windows::Forms::Button());
            this->SuspendLayout();
            // 
            // textBox1
            // 
            this->textBox1->BackColor = System::Drawing::SystemColors::ButtonHighlight;
            this->textBox1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 15.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
                static_cast<System::Byte>(204)));
            this->textBox1->Location = System::Drawing::Point(12, 12);
            this->textBox1->Name = L"textBox1";
            this->textBox1->ReadOnly = true;
            this->textBox1->Size = System::Drawing::Size(189, 31);
            this->textBox1->TabIndex = 12;
            this->textBox1->TextAlign = System::Windows::Forms::HorizontalAlignment::Right;
            // 
            // button1
            // 
            this->button1->Location = System::Drawing::Point(12, 68);
            this->button1->Name = L"button1";
            this->button1->Size = System::Drawing::Size(37, 35);
            this->button1->TabIndex = 13;
            this->button1->Text = L"1";
            this->button1->UseVisualStyleBackColor = true;
            this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
            // 
            // button2
            // 
            this->button2->Location = System::Drawing::Point(55, 68);
            this->button2->Name = L"button2";
            this->button2->Size = System::Drawing::Size(37, 35);
            this->button2->TabIndex = 14;
            this->button2->Text = L"2";
            this->button2->UseVisualStyleBackColor = true;
            this->button2->Click += gcnew System::EventHandler(this, &Form1::button2_Click);
            // 
            // button3
            // 
            this->button3->Location = System::Drawing::Point(98, 68);
            this->button3->Name = L"button3";
            this->button3->Size = System::Drawing::Size(37, 35);
            this->button3->TabIndex = 15;
            this->button3->Text = L"3";
            this->button3->UseVisualStyleBackColor = true;
            this->button3->Click += gcnew System::EventHandler(this, &Form1::button3_Click);
            // 
            // button4
            // 
            this->button4->Location = System::Drawing::Point(12, 109);
            this->button4->Name = L"button4";
            this->button4->Size = System::Drawing::Size(37, 35);
            this->button4->TabIndex = 16;
            this->button4->Text = L"4";
            this->button4->UseVisualStyleBackColor = true;
            this->button4->Click += gcnew System::EventHandler(this, &Form1::button4_Click);
            // 
            // button5
            // 
            this->button5->Location = System::Drawing::Point(55, 109);
            this->button5->Name = L"button5";
            this->button5->Size = System::Drawing::Size(37, 35);
            this->button5->TabIndex = 17;
            this->button5->Text = L"5";
            this->button5->UseVisualStyleBackColor = true;
            this->button5->Click += gcnew System::EventHandler(this, &Form1::button5_Click);
            // 
            // button6
            // 
            this->button6->Location = System::Drawing::Point(98, 109);
            this->button6->Name = L"button6";
            this->button6->Size = System::Drawing::Size(37, 35);
            this->button6->TabIndex = 18;
            this->button6->Text = L"6";
            this->button6->UseVisualStyleBackColor = true;
            this->button6->Click += gcnew System::EventHandler(this, &Form1::button6_Click);
            // 
            // button7
            // 
            this->button7->Location = System::Drawing::Point(12, 150);
            this->button7->Name = L"button7";
            this->button7->Size = System::Drawing::Size(37, 35);
            this->button7->TabIndex = 19;
            this->button7->Text = L"7";
            this->button7->UseVisualStyleBackColor = true;
            this->button7->Click += gcnew System::EventHandler(this, &Form1::button7_Click);
            // 
            // button8
            // 
            this->button8->Location = System::Drawing::Point(55, 150);
            this->button8->Name = L"button8";
            this->button8->Size = System::Drawing::Size(37, 35);
            this->button8->TabIndex = 20;
            this->button8->Text = L"8";
            this->button8->UseVisualStyleBackColor = true;
            this->button8->Click += gcnew System::EventHandler(this, &Form1::button8_Click);
            // 
            // button9
            // 
            this->button9->Location = System::Drawing::Point(98, 150);
            this->button9->Name = L"button9";
            this->button9->Size = System::Drawing::Size(37, 35);
            this->button9->TabIndex = 21;
            this->button9->Text = L"9";
            this->button9->UseVisualStyleBackColor = true;
            this->button9->Click += gcnew System::EventHandler(this, &Form1::button9_Click);
            // 
            // button10
            // 
            this->button10->Location = System::Drawing::Point(12, 191);
            this->button10->Name = L"button10";
            this->button10->Size = System::Drawing::Size(37, 35);
            this->button10->TabIndex = 22;
            this->button10->Text = L"00";
            this->button10->UseVisualStyleBackColor = true;
            this->button10->Click += gcnew System::EventHandler(this, &Form1::button10_Click);
            // 
            // button11
            // 
            this->button11->Location = System::Drawing::Point(55, 191);
            this->button11->Name = L"button11";
            this->button11->Size = System::Drawing::Size(37, 35);
            this->button11->TabIndex = 23;
            this->button11->Text = L"0";
            this->button11->UseVisualStyleBackColor = true;
            this->button11->Click += gcnew System::EventHandler(this, &Form1::button11_Click);
            // 
            // button12
            // 
            this->button12->Location = System::Drawing::Point(98, 191);
            this->button12->Name = L"button12";
            this->button12->Size = System::Drawing::Size(37, 35);
            this->button12->TabIndex = 24;
            this->button12->Text = L".";
            this->button12->UseVisualStyleBackColor = true;
            this->button12->Click += gcnew System::EventHandler(this, &Form1::button12_Click);
            // 
            // button13
            // 
            this->button13->Location = System::Drawing::Point(164, 68);
            this->button13->Name = L"button13";
            this->button13->Size = System::Drawing::Size(37, 35);
            this->button13->TabIndex = 25;
            this->button13->Text = L"+";
            this->button13->UseVisualStyleBackColor = true;
            this->button13->Click += gcnew System::EventHandler(this, &Form1::button13_Click);
            // 
            // button14
            // 
            this->button14->Location = System::Drawing::Point(164, 109);
            this->button14->Name = L"button14";
            this->button14->Size = System::Drawing::Size(37, 35);
            this->button14->TabIndex = 26;
            this->button14->Text = L"--";
            this->button14->UseVisualStyleBackColor = true;
            this->button14->Click += gcnew System::EventHandler(this, &Form1::button14_Click);
            // 
            // button15
            // 
            this->button15->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Bottom) 
                | System::Windows::Forms::AnchorStyles::Left) 
                | System::Windows::Forms::AnchorStyles::Right));
            this->button15->Location = System::Drawing::Point(164, 150);
            this->button15->Name = L"button15";
            this->button15->Size = System::Drawing::Size(37, 35);
            this->button15->TabIndex = 27;
            this->button15->Text = L"x";
            this->button15->UseVisualStyleBackColor = true;
            this->button15->Click += gcnew System::EventHandler(this, &Form1::button15_Click);
            // 
            // button16
            // 
            this->button16->Location = System::Drawing::Point(164, 191);
            this->button16->Name = L"button16";
            this->button16->Size = System::Drawing::Size(37, 35);
            this->button16->TabIndex = 28;
            this->button16->Text = L"/";
            this->button16->UseVisualStyleBackColor = true;
            this->button16->Click += gcnew System::EventHandler(this, &Form1::button16_Click);
            // 
            // button17
            // 
            this->button17->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 11.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
                static_cast<System::Byte>(204)));
            this->button17->Location = System::Drawing::Point(12, 232);
            this->button17->Name = L"button17";
            this->button17->Size = System::Drawing::Size(189, 35);
            this->button17->TabIndex = 29;
            this->button17->Text = L"=";
            this->button17->UseVisualStyleBackColor = true;
            this->button17->Click += gcnew System::EventHandler(this, &Form1::button17_Click);
            // 
            // Form1
            // 
            this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
            this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
            this->CausesValidation = false;
            this->ClientSize = System::Drawing::Size(213, 279);
            this->Controls->Add(this->button17);
            this->Controls->Add(this->button16);
            this->Controls->Add(this->button15);
            this->Controls->Add(this->button14);
            this->Controls->Add(this->button13);
            this->Controls->Add(this->button12);
            this->Controls->Add(this->button11);
            this->Controls->Add(this->button10);
            this->Controls->Add(this->button9);
            this->Controls->Add(this->button8);
            this->Controls->Add(this->button7);
            this->Controls->Add(this->button6);
            this->Controls->Add(this->button5);
            this->Controls->Add(this->button4);
            this->Controls->Add(this->button3);
            this->Controls->Add(this->button2);
            this->Controls->Add(this->button1);
            this->Controls->Add(this->textBox1);
            this->HelpButton = true;
            this->MaximizeBox = false;
            this->MinimizeBox = false;
            this->Name = L"Form1";
            this->Text = L"Калькулятор beta";
            this->ResumeLayout(false);
            this->PerformLayout();
 
        }
 
#pragma endregion
long double a,b,rezult=0; //a,b-числа, rezult - результат действия с ними
short int make; //if(make==1) sum if 2 - -, if 3 *, if 4 - /
    private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
                if(textBox1->Text==Convert::ToString(rezult))  {textBox1->Clear();}
                textBox1->AppendText("1");
             }
private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e) {
             if(textBox1->Text==Convert::ToString(rezult))  {textBox1->Clear();}
                textBox1->AppendText("2");
         }
private: System::Void button3_Click(System::Object^  sender, System::EventArgs^  e) {
             if(textBox1->Text==Convert::ToString(rezult))  {textBox1->Clear();}
                textBox1->AppendText("3");
         }
private: System::Void button4_Click(System::Object^  sender, System::EventArgs^  e) {
             if(textBox1->Text==Convert::ToString(rezult))  {textBox1->Clear();}
                textBox1->AppendText("4");
         }
private: System::Void button5_Click(System::Object^  sender, System::EventArgs^  e) {
             if(textBox1->Text==Convert::ToString(rezult))  {textBox1->Clear();}
                textBox1->AppendText("5");
         }
private: System::Void button6_Click(System::Object^  sender, System::EventArgs^  e) {
             if(textBox1->Text==Convert::ToString(rezult))  {textBox1->Clear();}
                textBox1->AppendText("6");
         }
private: System::Void button7_Click(System::Object^  sender, System::EventArgs^  e) {            
             if(textBox1->Text==Convert::ToString(rezult))  {textBox1->Clear();}
                textBox1->AppendText("7");
         }
private: System::Void button8_Click(System::Object^  sender, System::EventArgs^  e) {
             if(textBox1->Text==Convert::ToString(rezult))  {textBox1->Clear();}
                textBox1->AppendText("8");
         }
private: System::Void button9_Click(System::Object^  sender, System::EventArgs^  e) {
             if(textBox1->Text==Convert::ToString(rezult))  {textBox1->Clear();}
                textBox1->AppendText("9");
         }
private: System::Void button10_Click(System::Object^  sender, System::EventArgs^  e) {
             if(textBox1->Text==Convert::ToString(rezult))  {textBox1->Clear();}
                textBox1->AppendText("00");
         }
private: System::Void button11_Click(System::Object^  sender, System::EventArgs^  e) {
             if(textBox1->Text==Convert::ToString(rezult))  {textBox1->Clear();}
                textBox1->AppendText("0");
         }
private: System::Void button12_Click(System::Object^  sender, System::EventArgs^  e) {
             
             if(textBox1->Text==Convert::ToString(rezult))  {textBox1->Clear();}
                textBox1->AppendText(".");
         }
 
 
 
         //Далее идут вычисления
 
 
 
private: System::Void button13_Click(System::Object^  sender, System::EventArgs^  e) {
             a=Convert::ToDouble(textBox1->Text);
             make=1;
             textBox1->Clear();
         }
private: System::Void button14_Click(System::Object^  sender, System::EventArgs^  e) {
             a=Convert::ToDouble(textBox1->Text);
             make=2;
         }
private: System::Void button15_Click(System::Object^  sender, System::EventArgs^  e) {
             a=Convert::ToDouble(textBox1->Text);
             make=3;
         }
private: System::Void button16_Click(System::Object^  sender, System::EventArgs^  e) {           
             a=Convert::ToDouble(textBox1->Text);
             make=4;
         }
private: System::Void button17_Click(System::Object^  sender, System::EventArgs^  e) {
             b=Convert::ToDouble(textBox1->Text);
             textBox1->Clear();
             switch(make){
             case 1: rezult=a+b; break;
             case 2: rezult=a-b; break;
             case 3: rezult=a*b; break;
             case 4: if(a){rezult=a/b; break;}
                     else MessageBox::Show("Деление на ноль невозможно");
             default: MessageBox::Show("Невозможно выполнить действие т.к. не выбрано действие");
             }
         }
};
}
Ошибки 1-13 error C2668: System::Convert::ToString: неоднозначный вызов перегруженной функции

Думаю, нельзя так прям в основном коде вводить собственные переменные.
1. Где для них место? Это надо создавать собственный .h-файл и подключать?
2. Как исправить эти ошибки?
3. Сабж
0
Programming
Эксперт
94731 / 64177 / 26122
Регистрация: 12.04.2006
Сообщений: 116,782
31.05.2013, 11:14
Ответы с готовыми решениями:

Как определить, какой символ был введен?
# include &lt;iostream&gt; # include &lt;iomanip&gt; using namespace std; # include &lt;conio.h&gt; void main()...

Есть ли какой-то способ узнать, что с консоли введен именно текст, а не цифры
Добрий день! Есть ли какой-то способ узнать что с консоли введен именно текст, а не цифри не...

В переменную типа char вводится символ с клавиатуры. Программа выдает сообщение о том, какой символ был введен
В переменную типа char вводится символ с клавиатуры. Программа выдает сообщение о том, какой символ...

Проверить введен-ли текст в TextBox
Привет. Как можно проверить введен ли текст в поле? У меня форма, я вписываю туда имя, фамилию,...

7
0 / 0 / 0
Регистрация: 17.05.2013
Сообщений: 24
31.05.2013, 11:44 2
Не совсем понимаю что ты делаешь в условии.
условие выполняется когда в textBox1 введён 0 то есть result?
Почему бы тебе не вытащить число в rezult и просто не сравнить его с 0?
или просто объяви переменную String^ st="0";
и в условии напиши if(textBox1->Text==st)
0
Комп_Оратор)
Эксперт по математике/физике
8949 / 4703 / 629
Регистрация: 04.12.2011
Сообщений: 13,999
Записей в блоге: 16
31.05.2013, 11:55 3
ViRusSia, посмотрите описание класса TextBox. Событие textChanged есть у всех контроллов имеющих свойство Text. Переменные можно объявить и определить по-разному. Так как Вы сделали тоже можно.
0
0 / 0 / 0
Регистрация: 12.02.2013
Сообщений: 21
31.05.2013, 12:37  [ТС] 4
sai1lor, ну когда калькулятор выполнил уже первое вычисление, пользователь захотел что-нибудь вычислить еще, так? А в TextBox еще остался результат прошлых вычислений. А как нам проверить что он там есть? Я решил сделать так.
Единственная загвоздка. При первом запуске программы в текстовом поле ничего нет и могут быть ошибки.
0 тут ни при чем!

IGPIGP, спасибо, попробую. Однако вылезает ошибка:
Ошибка 1 error C3845: Калькулятор::Form1::rezult: только статические данные-члены можно инициализировать внутри класс ссылки или типа, передаваемого по значению

Добавлено через 1 минуту
IGPIGP, убрал ненужное инициализирование нулем. Ушла ошибка. НО остались

Цитата Сообщение от ViRusSia Посмотреть сообщение
Ошибки 1-13 error C2668: System::Convert::ToString: неоднозначный вызов перегруженной функции
0
0 / 0 / 0
Регистрация: 17.05.2013
Сообщений: 24
31.05.2013, 13:24 5
ViRusSia. Код откомпилировал, ошибка была в том что не принимал тип long double, воспользуйся просто double
double a,b,rezult;
добавь строчку вывода результата
textBox1->Text=Convert::ToString(rezult);
и в 3-х действия очистку поля
textBox1->Clear();
C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#pragma endregion
        double a,b,rezult; //a,b-числа, rezult - результат действия с ними
        short int make; //if(make==1) sum if 2 - -, if 3 *, if 4 - /
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
 
            if(textBox1->Text==Convert::ToString(rezult))  
                textBox1->Clear();
            textBox1->AppendText("1");
             }
private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e) {
 
            if(textBox1->Text==Convert::ToString(rezult))  
                textBox1->Clear();
            textBox1->AppendText("2");
         }
private: System::Void button3_Click(System::Object^  sender, System::EventArgs^  e) {
 
             if(textBox1->Text==Convert::ToString(rezult))  
                textBox1->Clear();
            textBox1->AppendText("3");
         }
private: System::Void button4_Click(System::Object^  sender, System::EventArgs^  e) {
 
            if(textBox1->Text==Convert::ToString(rezult))  
                textBox1->Clear();
            textBox1->AppendText("4");
         }
private: System::Void button5_Click(System::Object^  sender, System::EventArgs^  e) {
 
            if(textBox1->Text==Convert::ToString(rezult))  
                textBox1->Clear();
            textBox1->AppendText("5");
         }
private: System::Void button6_Click(System::Object^  sender, System::EventArgs^  e) {
 
            if(textBox1->Text==Convert::ToString(rezult))  
                textBox1->Clear();
            textBox1->AppendText("6");
         }
private: System::Void button7_Click(System::Object^  sender, System::EventArgs^  e) {
 
            if(textBox1->Text==Convert::ToString(rezult))  
                textBox1->Clear();
            textBox1->AppendText("7");
         }
private: System::Void button8_Click(System::Object^  sender, System::EventArgs^  e) {
 
            if(textBox1->Text==Convert::ToString(rezult))  
                textBox1->Clear();
            textBox1->AppendText("8");
         }
private: System::Void button9_Click(System::Object^  sender, System::EventArgs^  e) {
            
            if(textBox1->Text==Convert::ToString(rezult))  
                textBox1->Clear();
            textBox1->AppendText("9");
         }
private: System::Void button10_Click(System::Object^  sender, System::EventArgs^  e) {
 
            if(textBox1->Text==Convert::ToString(rezult))  
                textBox1->Clear();
            textBox1->AppendText("00");
         }
private: System::Void button11_Click(System::Object^  sender, System::EventArgs^  e) {
 
            if(textBox1->Text==Convert::ToString(rezult))  
                textBox1->Clear();
            textBox1->AppendText("0");
         }
private: System::Void button12_Click(System::Object^  sender, System::EventArgs^  e) {
 
            if(textBox1->Text==Convert::ToString(rezult))  
                textBox1->Clear();
            textBox1->AppendText(".");
         }
private: System::Void button13_Click(System::Object^  sender, System::EventArgs^  e) {
 
             a=Convert::ToDouble(textBox1->Text);
             make=1;
             textBox1->Clear();
         }
private: System::Void button14_Click(System::Object^  sender, System::EventArgs^  e) {
 
             a=Convert::ToDouble(textBox1->Text);
             make=2;
             textBox1->Clear();
         }
private: System::Void button15_Click(System::Object^  sender, System::EventArgs^  e) {
 
             a=Convert::ToDouble(textBox1->Text);
             make=3;
             textBox1->Clear();
         }
private: System::Void button16_Click(System::Object^  sender, System::EventArgs^  e) {
 
             a=Convert::ToDouble(textBox1->Text);
             make=4;
             textBox1->Clear();
         }
private: System::Void button17_Click(System::Object^  sender, System::EventArgs^  e) {
 
             b=Convert::ToDouble(textBox1->Text);
             textBox1->Clear();
             switch(make){
             case 1: rezult=a+b; break;
             case 2: rezult=a-b; break;
             case 3: rezult=a*b; break;
             case 4: if(a){rezult=a/b; break;}
                     else MessageBox::Show("Деление на ноль невозможно");
             default: MessageBox::Show("Невозможно выполнить действие т.к. не выбрано действие");
             }
             textBox1->Text=Convert::ToString(rezult);
         }
0
Комп_Оратор)
Эксперт по математике/физике
8949 / 4703 / 629
Регистрация: 04.12.2011
Сообщений: 13,999
Записей в блоге: 16
31.05.2013, 13:36 6
ViRusSia, Вы пытаетесь сравнить double и long double. Несмотря на то, что внутренне это одно и тоже (в реализации Microsoft), компилятор формально прав. Уберите long в объявлении. Или вызовите функцию-член ToString(). Но дело даже не в этом. Так сравнивать числа с плавающей точкой нельзя, только если Вы не имеете ввиду сравнение их строковых представлений. Не вдаваясь в то что можно прочесть:
double eps=1E-6;
if(abs(a-b) < eps){/****/}//a и b double
Может лучше бы подтянуться в с++, например.
0
0 / 0 / 0
Регистрация: 12.02.2013
Сообщений: 21
31.05.2013, 17:10  [ТС] 7
Цитата Сообщение от sai1lor Посмотреть сообщение
Код откомпилировал, ошибка была в том что не принимал тип long double, воспользуйся просто double
double a,b,rezult;
добавь строчку вывода результата
textBox1->Text=Convert::ToString(rezult);
и в 3-х действия очистку поля
textBox1->Clear();
спасибо, действительно, зашугался и кучу тупых ошибок допустил

Добавлено через 3 минуты
Цитата Сообщение от IGPIGP Посмотреть сообщение
Может лучше бы подтянуться в с++, например.
Я начинающий. Вот только прочитал Шилдта с++ Базовый Курс, решил на Windows Forms перейти.
В чем конкретно? В чужих прогах разобраться, код изучать или что-то другое?
0
0 / 0 / 0
Регистрация: 12.02.2013
Сообщений: 21
31.05.2013, 17:14  [ТС] 8
Люди! Снова проблема. Откомпилировал, запустил. Вылетает необрабатываемое исключение при работе с double
Миниатюры
Как проверить что в textBox введен какой-то символ? Есть для этого какое-то событие?  
0
31.05.2013, 17:14
IT_Exp
Эксперт
87844 / 49110 / 22898
Регистрация: 17.06.2006
Сообщений: 92,604
31.05.2013, 17:14
Помогаю со студенческими работами здесь

Определить, какой символ был введен
Задание 5.11. Написать программу, в которой в переменную типа Char вводится символ с клавиатуры....

Ввод символа, и проверка, какой символ был введен (getchar)
Приветствую всех. Подскажите пожалуйста, как реализовать в консоле ввод символа, и потом проверку,...

Считать из этого файла какой-либо символ и записать этот символ в новый файл
здравствуйте , помогите с решением следующего задания: естьтекстовый файл vvod.txt, в нем записана...

Как получить/проверить нужный символ из textbox?
Добрый день, здравствуйте, приветствую. Нужно сделать так, что бы введенная строка начиналась с...

Событие KeyPress у TextBox. Как сделать один формат для различных TextBox?
Есть много TextBox'ов, в которые нужно вводить только числа, и больше никаких символов. На...

Проверить есть ли в DataGridView1 в Колонке 1 текст, который введён в TextBox1
Подскажите как проверить есть ли в dataGridView1 в Колонке 1 текст который введён в textbox1 .


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
8
Ответ Создать тему
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2024, CyberForum.ru