質問編集履歴
1
処理の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -73,3 +73,551 @@
|
|
73
73
|
End Sub
|
74
74
|
|
75
75
|
```
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
*追加
|
80
|
+
|
81
|
+
その他処理
|
82
|
+
|
83
|
+
```VBA
|
84
|
+
|
85
|
+
'-- 関数 --
|
86
|
+
|
87
|
+
'初期化関数
|
88
|
+
|
89
|
+
Public Sub Initialization()
|
90
|
+
|
91
|
+
WarningLabel = ""
|
92
|
+
|
93
|
+
End Sub
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
'計算関数
|
98
|
+
|
99
|
+
Public Sub Calculation(strVal)
|
100
|
+
|
101
|
+
Select Case strVal
|
102
|
+
|
103
|
+
'回転数
|
104
|
+
|
105
|
+
Case "RotationSpeed"
|
106
|
+
|
107
|
+
'テキストボックスが空ではない場合の処理
|
108
|
+
|
109
|
+
If RotationSpeedTextBox01 <> "" And RotationSpeedTextBox02 <> "" Then
|
110
|
+
|
111
|
+
'周速・ワーク直径を変数に代入
|
112
|
+
|
113
|
+
PeripheralVelocity = RotationSpeedTextBox01
|
114
|
+
|
115
|
+
WorkDiameter = RotationSpeedTextBox02
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
'回転数(min-1)の計算
|
120
|
+
|
121
|
+
RotationSpeed = PeripheralVelocity / (WorkDiameter * PI) * 1000
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
'回転数(min-1)をテキストボックスに表示
|
126
|
+
|
127
|
+
RotationSpeedTextBox03 = RotationSpeed
|
128
|
+
|
129
|
+
End If
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
'周速
|
134
|
+
|
135
|
+
Case "PeripheralVelocity"
|
136
|
+
|
137
|
+
'テキストボックスが空ではない場合の処理
|
138
|
+
|
139
|
+
If PeripheralVelocityTextBox01 <> "" And PeripheralVelocityTextBox02 <> "" Then
|
140
|
+
|
141
|
+
'回転数・ワーク直径を変数に代入
|
142
|
+
|
143
|
+
PeripheralVelocity = PeripheralVelocityTextBox01
|
144
|
+
|
145
|
+
WorkDiameter = PeripheralVelocityTextBox02
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
'周速の計算
|
150
|
+
|
151
|
+
PeripheralVelocity = PeripheralVelocity * WorkDiameter * PI / 1000
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
'周速をテキストボックスに表示
|
156
|
+
|
157
|
+
PeripheralVelocityTextBox03 = PeripheralVelocity
|
158
|
+
|
159
|
+
End If
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
'R長さ
|
164
|
+
|
165
|
+
Case "FilletLength"
|
166
|
+
|
167
|
+
'テキストボックスが空ではない場合の処理
|
168
|
+
|
169
|
+
If FilletLengthTextBox01 <> "" And FilletLengthTextBox02 <> "" Then
|
170
|
+
|
171
|
+
'R(半径)・角度を変数に代入
|
172
|
+
|
173
|
+
R = FilletLengthTextBox01
|
174
|
+
|
175
|
+
Angle = FilletLengthTextBox02
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
'長さの計算
|
180
|
+
|
181
|
+
Length = ((R * 2 * PI) / 360) * Angle
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
'長さをテキストボックスに表示
|
186
|
+
|
187
|
+
FilletLengthTextBox03 = Length
|
188
|
+
|
189
|
+
End If
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
'表面粗さ
|
194
|
+
|
195
|
+
Case "SurfaceTexture"
|
196
|
+
|
197
|
+
'テキストボックスが空ではない場合の処理
|
198
|
+
|
199
|
+
If SurfaceTextureTextBox01 <> "" And SurfaceTextureTextBox02 <> "" Then
|
200
|
+
|
201
|
+
'送り・ノーズRを変数に代入
|
202
|
+
|
203
|
+
Feed = SurfaceTextureTextBox01
|
204
|
+
|
205
|
+
NoseR = SurfaceTextureTextBox02
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
'表面粗さ(Rz)の計算
|
210
|
+
|
211
|
+
SurfaceTextureRz = ((Feed ^ 2) / (8 * NoseR)) * 1000
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
'表面粗さ(Ra)の計算
|
216
|
+
|
217
|
+
SurfaceTextureRa = (((Feed ^ 2) / (8 * NoseR)) * 1000) / 4
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
'表面粗さ(Rz)をテキストボックスに表示
|
222
|
+
|
223
|
+
SurfaceTextureTextBox03 = SurfaceTextureRz
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
'表面粗さ(Ra)をテキストボックスに表示
|
228
|
+
|
229
|
+
SurfaceTextureTextBox04 = SurfaceTextureRa
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
End If
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
'ドリル
|
238
|
+
|
239
|
+
Case "Drill"
|
240
|
+
|
241
|
+
'テキストボックスが空ではない場合の処理
|
242
|
+
|
243
|
+
If DrillTextBox01 <> "" And DrillTextBox02 <> "" And DrillTextBox03 <> "" _
|
244
|
+
|
245
|
+
And DrillTextBox04 <> "" Then
|
246
|
+
|
247
|
+
'切削長・穴数・回転数・送りを変数に代入
|
248
|
+
|
249
|
+
CuttingLength = DrillTextBox01
|
250
|
+
|
251
|
+
NumberOfHoles = DrillTextBox02
|
252
|
+
|
253
|
+
RotationSpeed = DrillTextBox03
|
254
|
+
|
255
|
+
Feed = DrillTextBox04
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
'サイクルタイムの計算
|
260
|
+
|
261
|
+
CycleTime = ((CuttingLength * NumberOfHoles) / (RotationSpeed * Feed)) * 60
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
'サイクルタイムをテキストボックスに表示
|
266
|
+
|
267
|
+
DrillTextBox05 = CycleTime
|
268
|
+
|
269
|
+
End If
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
'サイクルタイム
|
274
|
+
|
275
|
+
Case "CycleTime"
|
276
|
+
|
277
|
+
'テキストボックスが空ではない場合の処理
|
278
|
+
|
279
|
+
If CycleTimeTextBox01 <> "" And CycleTimeTextBox02 <> "" And CycleTimeTextBox03 <> "" Then
|
280
|
+
|
281
|
+
'切削長・回転数・送りを変数に代入
|
282
|
+
|
283
|
+
CuttingLength = CycleTimeTextBox01
|
284
|
+
|
285
|
+
RotationSpeed = CycleTimeTextBox02
|
286
|
+
|
287
|
+
Feed = CycleTimeTextBox03
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
'サイクルタイムの計算
|
292
|
+
|
293
|
+
CycleTime = (CuttingLength * 60) / (RotationSpeed * Feed)
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
'サイクルタイムをテキストボックスに表示
|
298
|
+
|
299
|
+
CycleTimeTextBox04 = CycleTime
|
300
|
+
|
301
|
+
End If
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
'エンドミル
|
306
|
+
|
307
|
+
Case "EndMill"
|
308
|
+
|
309
|
+
'テキストボックスが空ではない場合の処理
|
310
|
+
|
311
|
+
If EndMillTextBox01 <> "" And EndMillTextBox02 <> "" Then
|
312
|
+
|
313
|
+
'長さ・テーブル送りを変数に代入
|
314
|
+
|
315
|
+
Length = EndMillTextBox01
|
316
|
+
|
317
|
+
TableFeed = EndMillTextBox02
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
'時間の計算
|
322
|
+
|
323
|
+
TimeCal = Length * 60 / TableFeed
|
324
|
+
|
325
|
+
|
326
|
+
|
327
|
+
'時間をテキストボックスに表示
|
328
|
+
|
329
|
+
EndMillTextBox03 = TimeCal
|
330
|
+
|
331
|
+
End If
|
332
|
+
|
333
|
+
|
334
|
+
|
335
|
+
'テーブル送り
|
336
|
+
|
337
|
+
Case "TableFeed"
|
338
|
+
|
339
|
+
'テキストボックスが空ではない場合の処理
|
340
|
+
|
341
|
+
If TableFeedTextBox01 <> "" And TableFeedTextBox02 <> "" Then
|
342
|
+
|
343
|
+
'送り量(mm/rev)・回転数を変数に代入
|
344
|
+
|
345
|
+
FeedAmount = TableFeedTextBox01
|
346
|
+
|
347
|
+
RotationSpeed = TableFeedTextBox02
|
348
|
+
|
349
|
+
|
350
|
+
|
351
|
+
'テーブル送り(mm/min)の計算
|
352
|
+
|
353
|
+
TableFeed = FeedAmount * RotationSpeed
|
354
|
+
|
355
|
+
|
356
|
+
|
357
|
+
'テーブル送り(mm/min)をテキストボックスに表示
|
358
|
+
|
359
|
+
TableFeedTextBox03 = TableFeed
|
360
|
+
|
361
|
+
End If
|
362
|
+
|
363
|
+
|
364
|
+
|
365
|
+
'毎回転送り
|
366
|
+
|
367
|
+
Case "TransferEveryTime"
|
368
|
+
|
369
|
+
'テキストボックスが空ではない場合の処理
|
370
|
+
|
371
|
+
If EveryRotationAndMinuteTextBox01 <> "" And EveryRotationAndMinuteTextBox02 <> "" Then
|
372
|
+
|
373
|
+
'毎分送り(mm/min)・回転数を変数に代入
|
374
|
+
|
375
|
+
FeedEveryMinute = EveryRotationAndMinuteTextBox01
|
376
|
+
|
377
|
+
RotationSpeed = EveryRotationAndMinuteTextBox02
|
378
|
+
|
379
|
+
|
380
|
+
|
381
|
+
'毎回転送り(mm/rev)の計算
|
382
|
+
|
383
|
+
TransferEveryTime = FeedEveryMinute / RotationSpeed
|
384
|
+
|
385
|
+
|
386
|
+
|
387
|
+
'毎回転送り(mm/rev)をテキストボックスに表示
|
388
|
+
|
389
|
+
EveryRotationAndMinuteTextBox03 = TransferEveryTime
|
390
|
+
|
391
|
+
End If
|
392
|
+
|
393
|
+
|
394
|
+
|
395
|
+
'毎分送り
|
396
|
+
|
397
|
+
Case "FeedEveryMinute"
|
398
|
+
|
399
|
+
'テキストボックスが空ではない場合の処理
|
400
|
+
|
401
|
+
If EveryRotationAndMinuteTextBox04 <> "" And EveryRotationAndMinuteTextBox05 <> "" Then
|
402
|
+
|
403
|
+
'毎回転送り(mm/rev)・ノーズRを変数に代入
|
404
|
+
|
405
|
+
TransferEveryTime = EveryRotationAndMinuteTextBox04
|
406
|
+
|
407
|
+
NoseR = EveryRotationAndMinuteTextBox05
|
408
|
+
|
409
|
+
|
410
|
+
|
411
|
+
'毎分送り(mm/min)の計算
|
412
|
+
|
413
|
+
FeedEveryMinute = TransferEveryTime * NoseR
|
414
|
+
|
415
|
+
|
416
|
+
|
417
|
+
'毎分送り(mm/min)をテキストボックスに表示
|
418
|
+
|
419
|
+
EveryRotationAndMinuteTextBox06 = FeedEveryMinute
|
420
|
+
|
421
|
+
End If
|
422
|
+
|
423
|
+
|
424
|
+
|
425
|
+
'ねじ
|
426
|
+
|
427
|
+
Case "Screw"
|
428
|
+
|
429
|
+
'テキストボックスが空ではない場合の処理
|
430
|
+
|
431
|
+
If ScrewTextBox01 <> "" And ScrewTextBox02 <> "" Then
|
432
|
+
|
433
|
+
'回転数・ピッチを変数に代入
|
434
|
+
|
435
|
+
RotationSpeed = ScrewTextBox01
|
436
|
+
|
437
|
+
Pitch = ScrewTextBox02
|
438
|
+
|
439
|
+
|
440
|
+
|
441
|
+
'ねじ予備動作の計算
|
442
|
+
|
443
|
+
ScrewPreliminaryMotion = (RotationSpeed * Pitch) / 1800
|
444
|
+
|
445
|
+
|
446
|
+
|
447
|
+
'ネジ予備動作をテキストボックスに表示
|
448
|
+
|
449
|
+
ScrewTextBox03 = ScrewPreliminaryMotion
|
450
|
+
|
451
|
+
End If
|
452
|
+
|
453
|
+
|
454
|
+
|
455
|
+
'図面比率
|
456
|
+
|
457
|
+
Case "DrawingRatio"
|
458
|
+
|
459
|
+
'テキストボックスが空ではない場合の処理
|
460
|
+
|
461
|
+
If DrawingRatioTextBox01 <> "" And DrawingRatioTextBox02 <> "" _
|
462
|
+
|
463
|
+
And DrawingRatioTextBox04 <> "" Then
|
464
|
+
|
465
|
+
'図面長さ①・計測長さ①・計測長さ②を変数に代入
|
466
|
+
|
467
|
+
DrawingLength01 = DrawingRatioTextBox01
|
468
|
+
|
469
|
+
MeasurementLength01 = DrawingRatioTextBox02
|
470
|
+
|
471
|
+
MeasurementLength02 = DrawingRatioTextBox04
|
472
|
+
|
473
|
+
|
474
|
+
|
475
|
+
'図面長さ②の計算
|
476
|
+
|
477
|
+
DrawingLength02 = (DrawingLength01 * MeasurementLength02) / MeasurementLength01
|
478
|
+
|
479
|
+
|
480
|
+
|
481
|
+
'図面長さ②をテキストボックスに表示
|
482
|
+
|
483
|
+
DrawingRatioTextBox03 = DrawingLength02
|
484
|
+
|
485
|
+
End If
|
486
|
+
|
487
|
+
|
488
|
+
|
489
|
+
'中央長さ
|
490
|
+
|
491
|
+
Case "CenterLength"
|
492
|
+
|
493
|
+
'テキストボックスが空ではない場合の処理
|
494
|
+
|
495
|
+
If CenterLengthTextBox01 <> "" And CenterLengthTextBox02 <> "" Then
|
496
|
+
|
497
|
+
'外側・内側を変数に代入
|
498
|
+
|
499
|
+
Outside = CenterLengthTextBox01
|
500
|
+
|
501
|
+
Inside = CenterLengthTextBox02
|
502
|
+
|
503
|
+
|
504
|
+
|
505
|
+
'中央の計算
|
506
|
+
|
507
|
+
Center = (Outside + Inside) / 2
|
508
|
+
|
509
|
+
|
510
|
+
|
511
|
+
'中央をテキストボックスに表示
|
512
|
+
|
513
|
+
CenterLengthTextBox03 = Center
|
514
|
+
|
515
|
+
End If
|
516
|
+
|
517
|
+
End Select
|
518
|
+
|
519
|
+
End Sub
|
520
|
+
|
521
|
+
|
522
|
+
|
523
|
+
'エラー振り分け関数
|
524
|
+
|
525
|
+
Public Sub ErrorAllocation(ErrNum)
|
526
|
+
|
527
|
+
Select Case ErrNum
|
528
|
+
|
529
|
+
'オーバーフローした場合
|
530
|
+
|
531
|
+
Case OVERFLOW_ERROR
|
532
|
+
|
533
|
+
'WarningLabelにエラーを表示する
|
534
|
+
|
535
|
+
WarningLabel = OVERFLOW_ERROR_WARNING
|
536
|
+
|
537
|
+
|
538
|
+
|
539
|
+
'0で除算した場合
|
540
|
+
|
541
|
+
Case DIVISION_BY_ZERO_ERROR
|
542
|
+
|
543
|
+
'WarningLabelにエラーを表示する
|
544
|
+
|
545
|
+
WarningLabel = DIVISION_BY_ZERO_ERROR_WARNING
|
546
|
+
|
547
|
+
|
548
|
+
|
549
|
+
'型が一致しない場合
|
550
|
+
|
551
|
+
Case TYPE_ERROR
|
552
|
+
|
553
|
+
'WarningLabelにエラーを表示する
|
554
|
+
|
555
|
+
WarningLabel = TYPE_ERROR_WARNING
|
556
|
+
|
557
|
+
End Select
|
558
|
+
|
559
|
+
End Sub
|
560
|
+
|
561
|
+
|
562
|
+
|
563
|
+
'キャンセルコマンド関数
|
564
|
+
|
565
|
+
Private Sub CancelCommandButton_Click()
|
566
|
+
|
567
|
+
Unload Me
|
568
|
+
|
569
|
+
End Sub
|
570
|
+
|
571
|
+
|
572
|
+
|
573
|
+
Private Sub MultiPage_Change()
|
574
|
+
|
575
|
+
'初期化
|
576
|
+
|
577
|
+
Initialization
|
578
|
+
|
579
|
+
End Sub
|
580
|
+
|
581
|
+
|
582
|
+
|
583
|
+
'中間処理
|
584
|
+
|
585
|
+
Public Sub IntermediateProc(CalItem)
|
586
|
+
|
587
|
+
'エラーハンドリング
|
588
|
+
|
589
|
+
On Error GoTo ErrorHandler
|
590
|
+
|
591
|
+
|
592
|
+
|
593
|
+
'初期化
|
594
|
+
|
595
|
+
Initialization
|
596
|
+
|
597
|
+
|
598
|
+
|
599
|
+
'計算関数
|
600
|
+
|
601
|
+
Calculation (CalItem)
|
602
|
+
|
603
|
+
|
604
|
+
|
605
|
+
'エラーがない場合はここで終了
|
606
|
+
|
607
|
+
Exit Sub
|
608
|
+
|
609
|
+
|
610
|
+
|
611
|
+
'エラーハンドラー
|
612
|
+
|
613
|
+
ErrorHandler:
|
614
|
+
|
615
|
+
'エラーごとに振り分ける
|
616
|
+
|
617
|
+
ErrNum = Err.Number
|
618
|
+
|
619
|
+
ErrorAllocation (ErrNum)
|
620
|
+
|
621
|
+
End Sub
|
622
|
+
|
623
|
+
```
|