Форум программистов, компьютерный форум, киберфорум
Delphi для начинающих
Войти
Регистрация
Восстановить пароль
Карта форума Темы раздела Блоги Сообщество Поиск Заказать работу  
 
Рейтинг 5.00/3: Рейтинг темы: голосов - 3, средняя оценка - 5.00
0 / 0 / 0
Регистрация: 10.10.2016
Сообщений: 187
1

Калькулятор доработки

27.02.2017, 23:17. Показов 566. Ответов 6
Метки нет (Все метки)

Author24 — интернет-сервис помощи студентам
Добрый вечер возникла проблема с калькулятором. В общем преподаватель попросила так: чтобы при вводе , была на окне edit 1: 0, и после этого писалось любое число, теперь при вводе 2,5 у меня вводит не 2,5 а 20,5 как это исправить вот код помогите пожалуйста!!!!
Delphi
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
unit Unit1;
 
interface
 
uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
 
type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    Button5: TButton;
    Button6: TButton;
    Button7: TButton;
    Button8: TButton;
    Button9: TButton;
    Button10: TButton;
    Button11: TButton;
    Button12: TButton;
    Button13: TButton;
    Button14: TButton;
    Button15: TButton;
    Button16: TButton;
    Button17: TButton;
    Button19: TButton;
    Button20: TButton;
    Button21: TButton;
    Button22: TButton;
    procedure Edit1KeyPress(Sender: TObject; var Key: Char);
    procedure Edit1Change(Sender: TObject);
    procedure Button7Click(Sender: TObject);
    procedure Button8Click(Sender: TObject);
    procedure Button9Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure Button5Click(Sender: TObject);
    procedure Button6Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button11Click(Sender: TObject);
    procedure Button10Click(Sender: TObject);
    procedure Button15Click(Sender: TObject);
    procedure Button14Click(Sender: TObject);
    procedure Button13Click(Sender: TObject);
    procedure Button12Click(Sender: TObject);
    procedure Button20Click(Sender: TObject);
    procedure Button16Click(Sender: TObject);
    procedure Button18Click(Sender: TObject);
    procedure Button17Click(Sender: TObject);
    procedure Button21Click(Sender: TObject);
    procedure Button19Click(Sender: TObject);
    procedure Button22Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
 
var
  Form1: TForm1;
  a,b,d:extended;
  c:char;
  z,z1:integer;
 
implementation
 
{$R *.dfm}
 
procedure TForm1.Button10Click(Sender: TObject);
var s:string;
begin
if edit1.Text='0' then
begin edit1.Text:='0,';
end;
if pos(',',edit1.Text)=0 then
Edit1.Text := Edit1.Text + '0,' ;
end;
 
 
procedure TForm1.Button11Click(Sender: TObject);
begin
Edit1.Text:=edit1.Text+'0';
if edit1.Text='00' then
edit1.Text:='0';
if z=1 then begin
  edit1.Text:='';
   z:=0;
end;
end;
 
procedure TForm1.Button12Click(Sender: TObject);
begin
z1:=3;
if edit1.Text<>'' then
a:=strtofloat(edit1.Text);
c:='/';
z:=1;
end;
 
procedure TForm1.Button13Click(Sender: TObject);
begin
 
if edit1.Text<>'' then
a:=strtofloat(edit1.Text);
c:='*';
z:=1;
end;
 
procedure TForm1.Button14Click(Sender: TObject);
begin
if edit1.Text<>'' then
a:=strtofloat(edit1.Text);
c:='-';
z:=1;
end;
 
procedure TForm1.Button15Click(Sender: TObject);
begin
if edit1.Text<>'' then
a:=strtofloat(edit1.Text);
c:='+';
z:=1;
end;
 
procedure TForm1.Button16Click(Sender: TObject);
begin
edit1.Text:=floattostr(sqrt(strtofloat(Edit1.Text)));
end;
 
procedure TForm1.Button17Click(Sender: TObject);
var
s:string;
begin
if edit1.Text<>'' then
edit1.Text:=
floattostr(strtofloat(edit1.Text)*strtofloat(edit1.Text));
end;
 
procedure TForm1.Button18Click(Sender: TObject);
begin
edit1.Text:= edit1.Text+'-' ;
end;
 
procedure TForm1.Button19Click(Sender: TObject);
begin
edit1.Clear;
end;
 
procedure TForm1.Button1Click(Sender: TObject);
begin
z1:=3;
if edit1.Text='0' then
edit1.Text:='';
if z=1 then begin
  edit1.Text:='';
   z:=0;
end;
edit1.Text:=edit1.Text+'7';
end;
 
procedure TForm1.Button20Click(Sender: TObject);
begin
 if edit1.Text<>'' then
 b:=strtofloat(edit1.Text);
 case c of
 '+':d:=a+b;
 '-':d:=a-b;
 '*':d:=a*b;
 '/':
 begin
 if edit1.Text<>'' then
 b:=strtofloat(edit1.Text);
 if b=0 then
 showmessage('На ноль делить нельзя!') else
 d:=a/b;
 end;
 end;
 edit1.Text:=floattostr(d);
end;
 
procedure TForm1.Button21Click(Sender: TObject);
var
s:string;
begin
s:=edit1.Text;
delete(s,length(s),1);
edit1.Text:=s;
end;
 
procedure TForm1.Button22Click(Sender: TObject);
begin
close();
end;
 
procedure TForm1.Button2Click(Sender: TObject);
begin
z1:=3;
if edit1.Text='0' then
edit1.Text:='';
if z=1 then begin
  edit1.Text:='';
   z:=0;
end;
edit1.Text:=edit1.Text+'8';
end;
 
procedure TForm1.Button3Click(Sender: TObject);
begin
z1:=3;
if edit1.Text='0' then
edit1.Text:='';
if z=1 then begin
  edit1.Text:='';
   z:=0;
end;
edit1.Text:=edit1.Text+'9';
end;
 
procedure TForm1.Button4Click(Sender: TObject);
begin
z1:=3;
if edit1.Text='0' then
if z=1 then begin
  edit1.Text:='';
   z:=0;
end;
edit1.Text:=edit1.Text+'4';
end;
 
procedure TForm1.Button5Click(Sender: TObject);
begin
z1:=3;
if edit1.Text='0' then
edit1.Text:='';
if z=1 then begin
  edit1.Text:='';
   z:=0;
end;
edit1.Text:=edit1.Text+'5';
end;
 
procedure TForm1.Button6Click(Sender: TObject);
begin
z1:=3;
if edit1.Text='0' then
edit1.Text:='';
if z=1 then begin
  edit1.Text:='';
   z:=0;
end;
edit1.Text:=edit1.Text+'6';
end;
 
procedure TForm1.Button7Click(Sender: TObject);
begin
z1:=3;
if edit1.Text='0' then
edit1.Text:='';
if z=1 then begin
  edit1.Text:='';
   z:=0;
end;
z:=3;
edit1.Text:=edit1.Text+'1';
 
end;
 
procedure TForm1.Button8Click(Sender: TObject);
begin
z1:=3;
if edit1.Text='0' then
edit1.Text:='';
if z=1 then begin
  edit1.Text:='';
   z:=0;
end;
edit1.Text:=edit1.Text+'2';
 
end;
 
procedure TForm1.Button9Click(Sender: TObject);
begin
z1:=3;
if edit1.Text='0' then
edit1.Text:='';
if z=1 then begin
  edit1.Text:='';
   z:=0;
end;
edit1.Text:=edit1.Text+'3';
 
end;
 
procedure TForm1.Edit1Change(Sender: TObject);
var
i,n:integer;
begin
n:=pos(',',edit1.text);
for i:=n+1 to length(edit1.text) do
if edit1.text[i]=',' then
edit1.clear;
end;
 
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
case key of
'0'..'9',',':;
else key:=#0;
end;
end;
 
end.
0
Programming
Эксперт
94731 / 64177 / 26122
Регистрация: 12.04.2006
Сообщений: 116,782
27.02.2017, 23:17
Ответы с готовыми решениями:

RichEdit и доработки
Добрый день форумчане. У меня вопрос, имеется компонент RichEdit, редактор rtf документов, хочу...

Delphi доработки Project1.
Всем привет. Хочу написать программку - чекер, но как всегда появляются ошибки. -Значит на форме...

Небольшие доработки
Здравствуйте уважаемые участники. Требуется довести программу до ума. Это база данных, нужно...

Небольшие доработки
Доброго времени суток. Имеется база(слизаная с топика &quot;делимся наработками&quot;). Но суть не в...

6
843 / 738 / 342
Регистрация: 22.09.2012
Сообщений: 5,034
28.02.2017, 09:25 2
Цитата Сообщение от Secret_Volga Посмотреть сообщение
была на окне edit 1: 0
А зачем в эдит- поле тебе при запуске 1: 0 показывать, может просто 0 лучше?
0
Модератор
9261 / 6039 / 2379
Регистрация: 21.01.2014
Сообщений: 25,802
Записей в блоге: 3
28.02.2017, 10:33 3
Secret_Volga, ты же в новой версии Delphi работаешь: используй свойство Эдита TextHint. Напиши там просто 0, и теперь, если эдит пуст - в нем будет отображаться значение 0, если не пуст - то отображается то, что написали
0
0 / 0 / 0
Регистрация: 10.10.2016
Сообщений: 187
28.02.2017, 11:59  [ТС] 4
У меня теперь при вводе числа 1,2 вводит 10,2 как это исправить не изменяя запятую
0
Модератор
9261 / 6039 / 2379
Регистрация: 21.01.2014
Сообщений: 25,802
Записей в блоге: 3
28.02.2017, 13:33 5
Цитата Сообщение от Secret_Volga Посмотреть сообщение
У меня теперь...
после чего "теперь"?
0
0 / 0 / 0
Регистрация: 10.10.2016
Сообщений: 187
28.02.2017, 19:06  [ТС] 6
Я ничего не делал не изменял мне надо как я еще попросил вначале, но так никто и не ответил, а тот ответ не подходит что нужно в коде изменить?
0
Модератор
9261 / 6039 / 2379
Регистрация: 21.01.2014
Сообщений: 25,802
Записей в блоге: 3
02.03.2017, 15:42 7
Цитата Сообщение от Secret_Volga Посмотреть сообщение
Я ничего не делал не изменял
Цитата Сообщение от Secret_Volga Посмотреть сообщение
а тот ответ не подходит
Я ничего не делал, не пробовал, но то, что сказали - не правильно...
Ну-ну...
0
02.03.2017, 15:42
IT_Exp
Эксперт
87844 / 49110 / 22898
Регистрация: 17.06.2006
Сообщений: 92,604
02.03.2017, 15:42
Помогаю со студенческими работами здесь

Программа для доработки
Помогите пожалуйста доработать программу

Проблема доработки скомпилированного js
У меня есть скомпилированный js файл, где вместе пару библиотек, а так же некоторый...

Доработки в существующей базе
Поставлена следующая задача: Структура компании. Фирма &quot;А&quot; получает 90% товара от общего...

8800GTX требует доработки!
Здравствуйте товарищи! имеется видеокарта asus geforce 8800, под нагрузкой грелась, разобрал чтобы...


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

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