Форум программистов, компьютерный форум, киберфорум
C++/CLI Windows Forms
Войти
Регистрация
Восстановить пароль
Блоги Сообщество Поиск Заказать работу  
 
0 / 0 / 0
Регистрация: 28.10.2011
Сообщений: 208

Калькулятор (некоторые ошибки)

28.05.2013, 10:25. Показов 761. Ответов 0
Метки нет (Все метки)

Студворк — интернет-сервис помощи студентам
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
#pragma once
 
namespace clac_test {
 
    using namespace System;
    using namespace System::ComponentModel;
    using namespace System::Collections;
    using namespace System::Windows::Forms;
    using namespace System::Data;
    using namespace System::Drawing;
 
    bool n=0;
 
 
    /// <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;
            }
        }
    private: System::Windows::Forms::TextBox^  input1;
    protected: 
    private: System::Windows::Forms::Label^  label1;
    private: System::Windows::Forms::TextBox^  input2;
    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::Label^  label2;
    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;
 
    private:
        /// <summary>
        /// Требуется переменная конструктора.
        /// </summary>
        System::ComponentModel::Container ^components;
 
#pragma region Windows Form Designer generated code
        /// <summary>
        /// Обязательный метод для поддержки конструктора - не изменяйте
        /// содержимое данного метода при помощи редактора кода.
        /// </summary>
        void InitializeComponent(void)
        {
            this->input1 = (gcnew System::Windows::Forms::TextBox());
            this->label1 = (gcnew System::Windows::Forms::Label());
            this->input2 = (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->label2 = (gcnew System::Windows::Forms::Label());
            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();
            // 
            // input1
            // 
            this->input1->Location = System::Drawing::Point(153, 12);
            this->input1->Name = L"input1";
            this->input1->Size = System::Drawing::Size(100, 20);
            this->input1->TabIndex = 0;
            // 
            // label1
            // 
            this->label1->AutoSize = true;
            this->label1->Location = System::Drawing::Point(179, 35);
            this->label1->Name = L"label1";
            this->label1->Size = System::Drawing::Size(0, 13);
            this->label1->TabIndex = 1;
            // 
            // input2
            // 
            this->input2->Location = System::Drawing::Point(153, 62);
            this->input2->Name = L"input2";
            this->input2->Size = System::Drawing::Size(100, 20);
            this->input2->TabIndex = 2;
            // 
            // button1
            // 
            this->button1->Location = System::Drawing::Point(164, 178);
            this->button1->Name = L"button1";
            this->button1->Size = System::Drawing::Size(75, 37);
            this->button1->TabIndex = 3;
            this->button1->Text = L"Enter";
            this->button1->UseVisualStyleBackColor = true;
            this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
            // 
            // button2
            // 
            this->button2->Location = System::Drawing::Point(163, 149);
            this->button2->Name = L"button2";
            this->button2->Size = System::Drawing::Size(75, 23);
            this->button2->TabIndex = 4;
            this->button2->Text = L"+";
            this->button2->UseVisualStyleBackColor = true;
            this->button2->Click += gcnew System::EventHandler(this, &Form1::button2_Click);
            // 
            // button3
            // 
            this->button3->Location = System::Drawing::Point(244, 149);
            this->button3->Name = L"button3";
            this->button3->Size = System::Drawing::Size(75, 23);
            this->button3->TabIndex = 5;
            this->button3->Text = L"-";
            this->button3->UseVisualStyleBackColor = true;
            this->button3->Click += gcnew System::EventHandler(this, &Form1::button3_Click);
            // 
            // button4
            // 
            this->button4->Location = System::Drawing::Point(82, 185);
            this->button4->Name = L"button4";
            this->button4->Size = System::Drawing::Size(75, 23);
            this->button4->TabIndex = 6;
            this->button4->Text = L"/";
            this->button4->UseVisualStyleBackColor = true;
            this->button4->Click += gcnew System::EventHandler(this, &Form1::button4_Click);
            // 
            // button5
            // 
            this->button5->Location = System::Drawing::Point(82, 149);
            this->button5->Name = L"button5";
            this->button5->Size = System::Drawing::Size(75, 23);
            this->button5->TabIndex = 7;
            this->button5->Text = L"*";
            this->button5->UseVisualStyleBackColor = true;
            this->button5->Click += gcnew System::EventHandler(this, &Form1::button5_Click);
            // 
            // button6
            // 
            this->button6->Location = System::Drawing::Point(244, 185);
            this->button6->Name = L"button6";
            this->button6->Size = System::Drawing::Size(75, 23);
            this->button6->TabIndex = 8;
            this->button6->Text = L"Clear";
            this->button6->UseVisualStyleBackColor = true;
            this->button6->Click += gcnew System::EventHandler(this, &Form1::button6_Click);
            // 
            // label2
            // 
            this->label2->AutoSize = true;
            this->label2->Location = System::Drawing::Point(190, 99);
            this->label2->Name = L"label2";
            this->label2->Size = System::Drawing::Size(37, 13);
            this->label2->TabIndex = 9;
            this->label2->Text = L"Ответ";
            // 
            // button7
            // 
            this->button7->Location = System::Drawing::Point(83, 228);
            this->button7->Name = L"button7";
            this->button7->Size = System::Drawing::Size(75, 23);
            this->button7->TabIndex = 10;
            this->button7->Text = L"1";
            this->button7->UseVisualStyleBackColor = true;
            this->button7->Click += gcnew System::EventHandler(this, &Form1::button7_Click);
            // 
            // button8
            // 
            this->button8->Location = System::Drawing::Point(164, 228);
            this->button8->Name = L"button8";
            this->button8->Size = System::Drawing::Size(75, 23);
            this->button8->TabIndex = 11;
            this->button8->Text = L"2";
            this->button8->UseVisualStyleBackColor = true;
            this->button8->Click += gcnew System::EventHandler(this, &Form1::button7_Click);
            // 
            // button9
            // 
            this->button9->Location = System::Drawing::Point(245, 228);
            this->button9->Name = L"button9";
            this->button9->Size = System::Drawing::Size(75, 23);
            this->button9->TabIndex = 12;
            this->button9->Text = L"3";
            this->button9->UseVisualStyleBackColor = true;
            this->button9->Click += gcnew System::EventHandler(this, &Form1::button7_Click);
            // 
            // button10
            // 
            this->button10->Location = System::Drawing::Point(83, 257);
            this->button10->Name = L"button10";
            this->button10->Size = System::Drawing::Size(75, 23);
            this->button10->TabIndex = 13;
            this->button10->Text = L"4";
            this->button10->UseVisualStyleBackColor = true;
            this->button10->Click += gcnew System::EventHandler(this, &Form1::button7_Click);
            // 
            // button11
            // 
            this->button11->Location = System::Drawing::Point(163, 257);
            this->button11->Name = L"button11";
            this->button11->Size = System::Drawing::Size(75, 23);
            this->button11->TabIndex = 14;
            this->button11->Text = L"5";
            this->button11->UseVisualStyleBackColor = true;
            this->button11->Click += gcnew System::EventHandler(this, &Form1::button7_Click);
            // 
            // button12
            // 
            this->button12->Location = System::Drawing::Point(244, 257);
            this->button12->Name = L"button12";
            this->button12->Size = System::Drawing::Size(75, 23);
            this->button12->TabIndex = 15;
            this->button12->Text = L"6";
            this->button12->UseVisualStyleBackColor = true;
            this->button12->Click += gcnew System::EventHandler(this, &Form1::button7_Click);
            // 
            // button13
            // 
            this->button13->Location = System::Drawing::Point(83, 286);
            this->button13->Name = L"button13";
            this->button13->Size = System::Drawing::Size(75, 23);
            this->button13->TabIndex = 16;
            this->button13->Text = L"7";
            this->button13->UseVisualStyleBackColor = true;
            this->button13->Click += gcnew System::EventHandler(this, &Form1::button7_Click);
            // 
            // button14
            // 
            this->button14->Location = System::Drawing::Point(163, 286);
            this->button14->Name = L"button14";
            this->button14->Size = System::Drawing::Size(75, 23);
            this->button14->TabIndex = 17;
            this->button14->Text = L"8";
            this->button14->UseVisualStyleBackColor = true;
            this->button14->Click += gcnew System::EventHandler(this, &Form1::button7_Click);
            // 
            // button15
            // 
            this->button15->Location = System::Drawing::Point(244, 286);
            this->button15->Name = L"button15";
            this->button15->Size = System::Drawing::Size(75, 23);
            this->button15->TabIndex = 18;
            this->button15->Text = L"9";
            this->button15->UseVisualStyleBackColor = true;
            this->button15->Click += gcnew System::EventHandler(this, &Form1::button7_Click);
            // 
            // button16
            // 
            this->button16->Location = System::Drawing::Point(163, 315);
            this->button16->Name = L"button16";
            this->button16->Size = System::Drawing::Size(75, 23);
            this->button16->TabIndex = 19;
            this->button16->Text = L"0";
            this->button16->UseVisualStyleBackColor = true;
            this->button16->Click += gcnew System::EventHandler(this, &Form1::button7_Click);
            // 
            // button17
            // 
            this->button17->Location = System::Drawing::Point(23, 99);
            this->button17->Name = L"button17";
            this->button17->Size = System::Drawing::Size(75, 23);
            this->button17->TabIndex = 20;
            this->button17->Text = L"1/x";
            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->ClientSize = System::Drawing::Size(399, 350);
            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->label2);
            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->input2);
            this->Controls->Add(this->label1);
            this->Controls->Add(this->input1);
            this->Name = L"Form1";
            this->Text = L"Калькулятор";
            this->ResumeLayout(false);
            this->PerformLayout();
 
        }
#pragma endregion
        char c; double x,y,d;
    private: System::Void button5_Click(System::Object^  sender, System::EventArgs^  e) {
                 this->label1->Text = "*";  c = '*';
                 n=true;
             }
private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e) {
              this->label1->Text = "+";  c = '+';
              n=true;
         }
private: System::Void button3_Click(System::Object^  sender, System::EventArgs^  e) {
              this->label1->Text = "-";  c = '-';
              n=true;
         }
private: System::Void button4_Click(System::Object^  sender, System::EventArgs^  e) {
              this->label1->Text = "/";  c = '/';
              n=true;
         }
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
             x= System::Convert::ToInt32(this->input1->Text);
             y=System::Convert::ToInt32(this->input2->Text);
             switch(c)
             {
             case '*':d=x*y;break;
             case '/':d=x/y;break;
             case '+':d=x+y;break;
             case '-':d=x-y;break;
             case 'x':d=1/x;break;
 
             }
             this->label2->Text=System::Convert::ToString(d);
         }
private: System::Void button6_Click(System::Object^  sender, System::EventArgs^  e) {
             this->input2->Text=""; this->input1->Text="";
             this->label1->Text="";this->label2->Text="";
            
 
         }
private: System::Void button7_Click(System::Object^  sender, System::EventArgs^  e) {
            if (!n) input1->Text+=((Button^)sender)->Text;
            else input2->Text+=((Button^)sender)->Text;
         }
private: System::Void button17_Click(System::Object^  sender, System::EventArgs^  e) {
             this->label1->Text = "1/x";  c = 'x';
              n=true;
 
         }
};
}
вот написал такой калькулятор и у меня возник вопрос: когда ввожу число в 1 строку и нажимаю функцию 1/х появляется ошибка мол вторая строка пустая, так вот как исправить это ?

и еще вопросик: ввожу первое число (нес клавиатуры , а кликами по кнопкам) потом нажимаю на действие и ввожу второе число - получается какой то результат, после этого когда нажимаю кнопочку clear и начинаю вводить число она вводиться только во вторую строку, как такое исправить ?
0
Programming
Эксперт
39485 / 9562 / 3019
Регистрация: 12.04.2006
Сообщений: 41,671
Блог
28.05.2013, 10:25
Ответы с готовыми решениями:

Некоторые ошибки компилятора
Доброго утра! Скажите пожалуйста UMBKTS.asm(18): instruction operands must be the same size UMBKTS.asm(15): cannot have segment...

Нужно исправить некоторые ошибки с формой онлайн заявки
Помогите пожалуйста! Не работает почему то кнопка &quot;отправить&quot; ! Ссылка на скачивание формы: http://rghost.ru/56589293 ...

Пароль. Задание сделано, но нужно исправить некоторые ошибки
Ввод идентификатора пользователя с клавиатуры. Данный идентификатор представляет собой последовательность символов a\ai—aN 5 где N -...

0
Надоела реклама? Зарегистрируйтесь и она исчезнет полностью.
inter-admin
Эксперт
29715 / 6470 / 2152
Регистрация: 06.03.2009
Сообщений: 28,500
Блог
28.05.2013, 10:25
Помогаю со студенческими работами здесь

пропали некоторые файлы после проверки диска на ошибки и восстановления
Здравствуйте! У меня две ОС параллельные - 7 -ка и 10-ка. Работаю в основном на 7-ке, но изредка захожу на 10-ку. Сегодня заметил, что...

Калькулятор: выбивает ошибки
Чтобы занести число в память, нужно нажать кнопку MS. Чтобы вызвать число из памяти, нужно нажать кнопку MR. фото...

Нужен человек готовый объяснить некоторые вещи и исправить мои ошибки
Я изучаю C++ и мне хотелось бы найти человека, который сможет мне рассказать и показать, как исправить мои ошибки по мере их поступления. ...

Программа калькулятор (Найти ошибки)
Здравствуйте уважаемые программисты. Мне очень нужна ваша помощь. Вкратце у меня курсовая на тему написать программу калькулятор на языке...

Калькулятор - найти ошибки в коде
Программу честно спилил с сайта, ругается в модуль GROUTPUT на 22 и на 24 строчку( 121 ошибочный спецификатор). Работает в совокупе с...


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

Или воспользуйтесь поиском по форуму:
1
Ответ Создать тему
Новые блоги и статьи
Оттенки серого
Argus19 18.03.2026
Оттенки серого Нашёл в интернете 3 прекрасных модуля: Модуль класса открытия диалога открытия/ сохранения файла на Win32 API; Модуль класса быстрого перекодирования цветного изображения в оттенки. . .
SDL3 для Desktop (MinGW): Рисуем цветные прямоугольники с помощью рисовальщика SDL3 на Си и C++
8Observer8 17.03.2026
Содержание блога Финальные проекты на Си и на C++: finish-rectangles-sdl3-c. zip finish-rectangles-sdl3-cpp. zip
Символические и жёсткие ссылки в Linux.
algri14 15.03.2026
Существует два типа ссылок — символические и жёсткие. Ссылка в Linux — это запись в каталоге, которая может указывать либо на inode «файла-ИСТОЧНИКА», тогда это будет «жёсткая ссылка» (hard link),. . .
[Owen Logic] Поддержание уровня воды в резервуаре количеством включённых насосов: моделирование и выбор регулятора
ФедосеевПавел 14.03.2026
Поддержание уровня воды в резервуаре количеством включённых насосов: моделирование и выбор регулятора ВВЕДЕНИЕ Выполняя задание на управление насосной группой заполнения резервуара,. . .
делаю науч статью по влиянию грибов на сукцессию
anaschu 13.03.2026
прикрепляю статью
SDL3 для Desktop (MinGW): Создаём пустое окно с нуля для 2D-графики на SDL3, Си и C++
8Observer8 10.03.2026
Содержание блога Финальные проекты на Си и на C++: hello-sdl3-c. zip hello-sdl3-cpp. zip Результат:
Установка CMake и MinGW 13.1 для сборки С и C++ приложений из консоли и из Qt Creator в EXE
8Observer8 10.03.2026
Содержание блога MinGW - это коллекция инструментов для сборки приложений в EXE. CMake - это система сборки приложений. Здесь описаны базовые шаги для старта программирования с помощью CMake и. . .
Как дизайн сайта влияет на конверсию: 7 решений, которые реально повышают заявки
Neotwalker 08.03.2026
Многие до сих пор воспринимают дизайн сайта как “красивую оболочку”. На практике всё иначе: дизайн напрямую влияет на то, оставит человек заявку или уйдёт через несколько секунд. Даже если у вас. . .
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2026, CyberForum.ru