-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path计算器.frm
506 lines (502 loc) · 15.4 KB
/
计算器.frm
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
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
VERSION 5.00
Begin VB.Form Yale的初代计算器
Caption = "计算器 v0.4 Bulid 07/06/2020"
ClientHeight = 4560
ClientLeft = 7635
ClientTop = 3300
ClientWidth = 4755
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
LinkTopic = "Form1"
ScaleHeight = 4560
ScaleWidth = 4755
Begin VB.CommandButton Cmd2
Caption = "Cos"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Index = 16
Left = 1750
TabIndex = 20
Top = 3960
Width = 495
End
Begin VB.CommandButton Cmd2
Caption = "Sin"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Index = 15
Left = 1080
TabIndex = 19
Top = 3960
Width = 495
End
Begin VB.CommandButton Cmd2
Caption = "√"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Index = 14
Left = 360
TabIndex = 18
Top = 3960
Width = 495
End
Begin VB.CommandButton Cmd4
Caption = "←"
Height = 615
Left = 3840
TabIndex = 17
Top = 240
Width = 735
End
Begin VB.CommandButton Cmd2
Caption = "^3"
BeginProperty Font
Name = "宋体"
Size = 15.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Index = 13
Left = 3840
TabIndex = 16
Top = 3240
Width = 495
End
Begin VB.CommandButton Cmd2
Caption = "ln"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Index = 12
Left = 3120
TabIndex = 15
Top = 3960
Width = 495
End
Begin VB.CommandButton Cmd2
Caption = "log"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Index = 11
Left = 2400
TabIndex = 14
Top = 3960
Width = 495
End
Begin VB.CommandButton Cmd2
Caption = "e^x"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Index = 10
Left = 3120
TabIndex = 13
Top = 3240
Width = 495
End
Begin VB.CommandButton Cmd2
Caption = "+/-"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Index = 9
Left = 2400
TabIndex = 12
Top = 1080
Width = 495
End
Begin VB.CommandButton Cmd2
Caption = "|x|"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Index = 8
Left = 2400
TabIndex = 11
Top = 3240
Width = 495
End
Begin VB.CommandButton Cmd2
Caption = "10^x"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Index = 7
Left = 3120
TabIndex = 10
Top = 2520
Width = 495
End
Begin VB.CommandButton Cmd2
Caption = "^x"
Height = 495
Index = 6
Left = 3840
TabIndex = 9
Top = 3960
Width = 495
End
Begin VB.CommandButton Cmd2
Caption = "^2"
BeginProperty Font
Name = "宋体"
Size = 15.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Index = 5
Left = 3840
TabIndex = 8
Top = 2520
Width = 495
End
Begin VB.CommandButton Cmd2
Caption = "Mod"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Index = 4
Left = 2400
TabIndex = 7
Top = 2520
Width = 495
End
Begin VB.CommandButton Cmd1
Caption = "0"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 855
Index = 0
Left = 720
TabIndex = 6
Top = 1800
Visible = 0 'False
Width = 855
End
Begin VB.CommandButton Cmd2
Caption = "÷"
BeginProperty Font
Name = "宋体"
Size = 15.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Index = 3
Left = 3840
TabIndex = 5
Top = 1800
Width = 495
End
Begin VB.CommandButton Cmd2
Caption = "×"
BeginProperty Font
Name = "宋体"
Size = 15.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Index = 2
Left = 3120
TabIndex = 4
Top = 1800
Width = 495
End
Begin VB.CommandButton Cmd2
Caption = "-"
BeginProperty Font
Name = "宋体"
Size = 15.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Index = 1
Left = 3840
TabIndex = 3
Top = 1080
Width = 495
End
Begin VB.CommandButton Cmd2
Caption = "+"
BeginProperty Font
Name = "宋体"
Size = 15.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Index = 0
Left = 3120
TabIndex = 2
Top = 1080
Width = 495
End
Begin VB.CommandButton Cmd3
Caption = "C"
BeginProperty Font
Name = "宋体"
Size = 15.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 2400
TabIndex = 1
Top = 1800
Width = 495
End
Begin VB.TextBox Text1
Alignment = 1 'Right Justify
BeginProperty Font
Name = "宋体"
Size = 18
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 615
Left = 120
TabIndex = 0
Top = 240
Width = 3615
End
End
Attribute VB_Name = "Yale的初代计算器"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public X1, X2 As Double: Public Y As String: Public a, p As Boolean
Private Sub Cmd1_Click(Index As Integer)
If Index <> 12 Then Text1.Text = Text1.Text & Cmd1(Index).Caption
If Index = 11 Then
Cmd1(11).Enabled = False
End If
If Index = 12 Then
X2 = Val(Text1.Text)
If Y = "+" Then X1 = X1 + X2
If Y = "-" Then X1 = X1 - X2
If Y = "×" Then X1 = X1 * X2
If Y = "÷" Then X1 = X1 / X2
If Y = "Mod" Then X1 = X1 Mod X2
If Y = "^2" Then X1 = X1 * X1
If Y = "^3" Then X1 = X1 ^ 3
If Y = "^x" Then X1 = X1 ^ X2
If Y = "10^x" Then X1 = 10 ^ X1
If Y = "^x" Then X1 = Abs(X1)
If Y = "e^x" Then X1 = Exp(X1)
If Y = "log" Then
If X1 <= 0 Then
MsgBox "无效数值", 0, "警告"
Text1.Text = X1
Text1.SetFocus
Else
X1 = Log(X1)
End If
End If
If Y = "ln" Then
If X1 <= 0 Then
MsgBox "无效数值", 0, "警告"
Text1.Text = X1
Text1.SetFocus
Else
X1 = Log(X1) / Log(2.718281828459)
End If
End If
If Y = "√" Then
If X1 < 0 Then
MsgBox "无效数值", 0, "警告"
Text1.Text = X1
Text1.SetFocus
Else
X1 = Sqr(X1)
End If
End If
If Y = "Sin" Then X1 = Sin(X1)
If Y = "Cos" Then X1 = (X1)
Text1.Text = X1
If InStr(Text1.Text, ".") = 0 Then
Cmd1(11).Enabled = True
Else
Cmd1(11).Enabled = False
End If
End If
End Sub
Private Sub Cmd2_Click(Index As Integer)
Cmd1(11).Enabled = True
If Index = 9 Then
If Sgn(Val(Text1.Text)) = -1 Then
Text1.Text = -Val(Text1.Text)
ElseIf Sgn(Val(Text1.Text)) = 1 Then
Text1.Text = "-" & Text1.Text
ElseIf Sgn(Val(Text1.Text)) = 0 Then
If a = False Then
Text1.Text = "-"
a = True
Else
Text1.Text = ""
a = False
End If
End If
Else
Y = Cmd2(Index).Caption
X1 = Val(Text1.Text)
Text1.Text = ""
End If
End Sub
Private Sub Cmd3_Click()
Text1.Text = ""
Cmd1(11).Enabled = True
End Sub
Private Sub Cmd4_Click()
If Text1.Text <> "" Then
Last = Right(Text1.Text, 1)
Text1.Text = Left(Text1.Text, Len(Text1.Text) - 1)
If Last = "." Then
Cmd1(11).Enabled = True
End If
End If
End Sub
Private Sub Form_Load()
For k = 1 To 12
Load Cmd1(k)
Next k
mtop = 1080
mwidth = 500
mheight = 500
For i = 1 To 4
mleft = 360
For j = 1 To 3
k = (i - 1) * 3 + j
Cmd1(k).Caption = k
If k = 10 Then k = 0: Cmd1(k).Caption = k
If k = 11 Then Cmd1(k).Caption = "."
If k = 12 Then Cmd1(k).Caption = "="
Cmd1(k).Visible = True
Cmd1(k).Width = mwidth
Cmd1(k).Height = mheight
Cmd1(k).Left = mleft
Cmd1(k).Top = mtop
Cmd1(k).FontSize = 12
Cmd1(k).FontBold = True
mleft = mleft + mwidth + 200
Next j
mtop = mtop + mheight + 220
Next i
MsgBox "版本v0.4" & vbCrLf & "修复内容:" & vbCrLf & "小数点输入修复" & vbCrLf & vbCrLf & "本软件仅供学习使用,有任何意见可联系作者QQ:1175592624", 0, "使用提示"
End Sub