-
Notifications
You must be signed in to change notification settings - Fork 0
/
frmCreateNewVehicle.frm
818 lines (787 loc) · 25.8 KB
/
frmCreateNewVehicle.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
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
VERSION 5.00
Object = "{CFC13920-9EF4-11D0-B72F-0000C04D4C0A}#6.0#0"; "mswless.ocx"
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX"
Begin VB.Form frmCreateNewVehicle
BorderStyle = 1 'Fixed Single
Caption = "Create New Vehicle"
ClientHeight = 7875
ClientLeft = 45
ClientTop = 390
ClientWidth = 7755
HelpContextID = 20
Icon = "frmCreateNewVehicle.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 7875
ScaleWidth = 7755
StartUpPosition = 2 'CenterScreen
Begin VB.TextBox txtLength
BeginProperty Font
Name = "Consolas"
Size = 11.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 480
Left = 360
TabIndex = 11
Top = 5880
Width = 3135
End
Begin VB.TextBox txtWidth
BeginProperty Font
Name = "Consolas"
Size = 11.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 480
Left = 4200
TabIndex = 12
Top = 5880
Width = 3135
End
Begin VB.TextBox txtQuantity
BeginProperty Font
Name = "Consolas"
Size = 11.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 480
Left = 4200
TabIndex = 5
Top = 3120
Width = 3135
End
Begin VB.TextBox txtYear
BeginProperty Font
Name = "Consolas"
Size = 11.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 480
Left = 360
TabIndex = 4
Top = 3120
Width = 3135
End
Begin MSComCtl2.DTPicker dtProductionStarted
Height = 495
Left = 360
TabIndex = 2
ToolTipText = "Year when the production started"
Top = 2160
Width = 3135
_ExtentX = 5530
_ExtentY = 873
_Version = 393216
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Consolas"
Size = 11.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
CustomFormat = "MM/yyyy"
Format = 97255427
CurrentDate = 44707
End
Begin MSComCtl2.DTPicker dtProductionEnded
Height = 495
Left = 4200
TabIndex = 3
ToolTipText = "Year when the production ended"
Top = 2160
Width = 3135
_ExtentX = 5530
_ExtentY = 873
_Version = 393216
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Consolas"
Size = 11.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
CustomFormat = "MM/yyyy"
Format = 97255427
CurrentDate = 44707
End
Begin MSWLess.WLText txtPrice
Height = 495
Left = 360
TabIndex = 6
ToolTipText = "Price per unit"
Top = 4080
Width = 3135
_ExtentX = 5530
_ExtentY = 873
_Version = 393216
ForeColor = -2147483640
BackColor = -2147483643
BorderStyle = 1
Appearance = 1
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Consolas"
Size = 11.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin VB.Label lblQuantity
Caption = "Quantity"
BeginProperty Font
Name = "Consolas"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 4200
TabIndex = 27
Top = 2880
Width = 3135
End
Begin VB.Label lblYearProduction
Caption = "Year of Production"
BeginProperty Font
Name = "Consolas"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 360
TabIndex = 26
Top = 2880
Width = 3135
End
Begin MSWLess.WLCommand btnReset
Height = 975
Left = 4080
TabIndex = 14
Top = 6720
Width = 2535
_ExtentX = 4471
_ExtentY = 1720
_Version = 393216
Caption = "&Reset"
ForeColor = -1
BackColor = -2147483633
Appearance = 1
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Consolas"
Size = 14.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin MSWLess.WLCommand btnCreate
Height = 975
Left = 960
TabIndex = 13
Top = 6720
Width = 2535
_ExtentX = 4471
_ExtentY = 1720
_Version = 393216
Caption = "&Create"
ForeColor = -1
BackColor = -2147483633
Appearance = 1
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Consolas"
Size = 14.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin VB.Label lblWidth
Caption = "Width"
BeginProperty Font
Name = "Consolas"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 4200
TabIndex = 25
Top = 5640
Width = 3135
End
Begin VB.Label lblLength
Caption = "Length"
BeginProperty Font
Name = "Consolas"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 360
TabIndex = 24
Top = 5640
Width = 3135
End
Begin MSWLess.WLOption optTransmission
Height = 495
Index = 1
Left = 6000
TabIndex = 8
ToolTipText = "Manual transmission"
Top = 4080
Width = 1335
_ExtentX = 2355
_ExtentY = 873
_Version = 393216
Caption = "Manual"
ForeColor = -2147483630
BackColor = -2147483633
Appearance = 1
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Consolas"
Size = 11.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin MSWLess.WLOption optTransmission
Height = 495
Index = 0
Left = 4200
TabIndex = 7
ToolTipText = "Automatic or CVT tansmission"
Top = 4080
Width = 1575
_ExtentX = 2778
_ExtentY = 873
_Version = 393216
Caption = "Automatic"
ForeColor = -2147483630
BackColor = -2147483633
Appearance = 1
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Consolas"
Size = 11.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin VB.Label lblPrice
Caption = "Price"
BeginProperty Font
Name = "Consolas"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 360
TabIndex = 23
Top = 3840
Width = 3135
End
Begin MSWLess.WLCombo cmbManufacturer
Height = 390
Left = 4200
TabIndex = 1
ToolTipText = "Manufacturer"
Top = 1200
Width = 3135
_ExtentX = 5530
_ExtentY = 688
_Version = 393216
Style = 2
ListCount = -14340
Text = "cmbManufacturer"
ForeColor = -2147483640
BackColor = -2147483643
Appearance = 1
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Consolas"
Size = 11.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
List = "frmCreateNewVehicle.frx":3AFA
End
Begin MSWLess.WLCombo cmbBodyStyle
Height = 390
Left = 4200
TabIndex = 10
ToolTipText = "Body Style"
Top = 5040
Width = 3135
_ExtentX = 5530
_ExtentY = 688
_Version = 393216
Style = 2
ListCount = -14300
Text = "cmbBodyStyle"
ForeColor = -2147483640
BackColor = -2147483643
Appearance = 1
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Consolas"
Size = 11.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
List = "frmCreateNewVehicle.frx":3B16
End
Begin MSWLess.WLCombo cmbClass
Height = 390
Left = 360
TabIndex = 9
ToolTipText = "Class"
Top = 5040
Width = 3135
_ExtentX = 5530
_ExtentY = 688
_Version = 393216
Style = 2
ListCount = -13860
Text = "cmbClass"
ForeColor = -2147483640
BackColor = -2147483643
Appearance = 1
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Consolas"
Size = 11.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
List = "frmCreateNewVehicle.frx":3D22
End
Begin VB.Label Label3
Caption = "Production Ended"
BeginProperty Font
Name = "Consolas"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 4200
TabIndex = 18
Top = 1920
Width = 3135
End
Begin MSWLess.WLText txtName
Height = 495
Left = 360
TabIndex = 0
ToolTipText = "Name of the vehicle model"
Top = 1200
Width = 3135
_ExtentX = 5530
_ExtentY = 873
_Version = 393216
ForeColor = -2147483640
BackColor = -2147483643
BorderStyle = 1
Appearance = 1
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Consolas"
Size = 11.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin VB.Label lblTitle
Alignment = 2 'Center
Caption = "Vehicle"
BeginProperty Font
Name = "Javanese Text"
Size = 24
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 735
Left = 240
TabIndex = 15
Top = 0
Width = 7215
End
Begin VB.Label lblName
Caption = "Name"
BeginProperty Font
Name = "Consolas"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 360
TabIndex = 16
Top = 960
Width = 3135
End
Begin VB.Label Label2
Caption = "Production Started"
BeginProperty Font
Name = "Consolas"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 360
TabIndex = 17
Top = 1920
Width = 3135
End
Begin VB.Label lblClass
Caption = "Class"
BeginProperty Font
Name = "Consolas"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 360
TabIndex = 20
Top = 4800
Width = 3135
End
Begin VB.Label lblBodyStyle
Caption = "Body Style"
BeginProperty Font
Name = "Consolas"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 4200
TabIndex = 19
Top = 4800
Width = 3135
End
Begin VB.Label lblManufacturer
Caption = "Manufacturer"
BeginProperty Font
Name = "Consolas"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 4200
TabIndex = 21
Top = 960
Width = 3135
End
Begin VB.Label lblTransmission
Caption = "Transmission"
BeginProperty Font
Name = "Consolas"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 4200
TabIndex = 22
Top = 3840
Width = 3135
End
End
Attribute VB_Name = "frmCreateNewVehicle"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public PreviousName As String
Dim AlreadyMarked As Boolean
Private Sub btnCreate_Click()
On Error GoTo ErrHandler
ExecuteSQL "Select * from Vehicle where Vehicle_Name = '" & txtName & "'"
If IsInformationValid Then
If btnCreate.Caption = "&Create" Then
If Not rs.EOF Then
MsgBox "Vehicle model already exists!", vbCritical, "Error"
Exit Sub
End If
rs.AddNew
MsgBox "New vehicle model added successfully!", vbOKOnly, "Information"
ElseIf btnCreate.Caption = "&Update" Then
If ModelExists(txtName) Then Exit Sub
MsgBox "Vehicle model updated successfully!", vbOKOnly, "Information"
End If
Else
MsgBox "Fill all the required spaces in the form", vbInformation, "Information"
CheckEmptyText
AlreadyMarked = True
Exit Sub
End If
rs!Vehicle_Name = txtName
rs!Manufacturer_ID = GetManufacturerID
rs!Production_Started = Format(CDate(dtProductionStarted), "MM/dd/YYYY")
rs!Production_Ended = Format(CDate(dtProductionEnded), "MM/dd/YYYY")
rs!Produced = txtYear
rs!Quantity = txtQuantity
rs!Price = CDbl(Replace(txtPrice, "$", ""))
If optTransmission(0).value = True Then
rs!Transmission = "Automatic"
Else
rs!Transmission = "Manual"
End If
rs!Class_ID = GetClassID
rs!Body_Style = cmbBodyStyle.Text
rs!Length = CDbl(Replace(txtLength.Text, " mm", ""))
rs!Width = CDbl(Replace(txtWidth.Text, " mm", ""))
rs!Available = True
rs.Update
AlreadyMarked = False
RemoveMark Me
ClearForm
Exit Sub
ErrHandler:
MsgBox "There was an error during the operation", vbCritical, "Error"
Exit Sub
End Sub
Function ModelExists(ModelName As String) As Boolean
Dim result As Boolean
ExecuteSQL2 "Select * from Vehicle where Vehicle_Name = '" & ModelName & "'"
If ModelName = PreviousName Then
result = False
ElseIf Not rs2.EOF And ModelName <> PreviousName Then
MsgBox "Vehicle model already exists!", vbCritical, "Error"
result = True
End If
ModelExists = result
End Function
Sub CheckEmptyText()
If Not AlreadyMarked Then
AddRequiredMark lblName, vbRed, txtName
AddRequiredMark lblManufacturer, vbRed, , cmbManufacturer
AddRequiredMark lblYearProduction, vbRed, txtYear
AddRequiredMark lblQuantity, vbRed, txtQuantity
AddRequiredMark lblPrice, vbRed, txtPrice
AddRequiredMark lblTransmission, vbRed, , , optTransmission
AddRequiredMark lblClass, vbRed, , cmbClass
AddRequiredMark lblBodyStyle, vbRed, , cmbBodyStyle
AddRequiredMark lblLength, vbRed, txtLength
AddRequiredMark lblWidth, vbRed, txtWidth
End If
End Sub
Function GetManufacturerID() As Integer
ExecuteSQL2 "Select * from Brand where Brand_Name = '" & cmbManufacturer.Text & "'"
GetManufacturerID = rs2.Fields!ID
End Function
Function GetClassID() As Integer
ExecuteSQL2 "Select * from Class where Class_Name = '" & cmbClass.Text & "'"
GetClassID = rs2.Fields!ID
End Function
Function IsInformationValid() As Boolean
If txtName.Text <> "" And cmbManufacturer.ListIndex <> -1 And _
txtQuantity.Text <> "" And txtPrice.Text <> "" And txtYear.Text <> "" And _
(optTransmission(0).value <> False Or optTransmission(1).value <> False) And _
cmbClass.ListIndex <> -1 And cmbBodyStyle.ListIndex <> -1 And _
txtLength.Text <> "" And txtWidth.Text <> "" Then
IsInformationValid = True
Else
IsInformationValid = False
End If
End Function
Private Sub btnReset_Click()
ClearForm
End Sub
Sub ClearForm()
RemoveMark Me
AlreadyMarked = False
txtName.Text = ""
cmbManufacturer.ListIndex = -1
optTransmission(0).value = False
optTransmission(1).value = False
cmbClass.ListIndex = -1
cmbBodyStyle.ListIndex = -1
dtProductionEnded.value = DateTime.Date
dtProductionStarted.value = DateTime.Date
txtYear.Text = ""
txtQuantity.Text = ""
txtPrice.Text = ""
txtLength.Text = ""
txtWidth.Text = ""
End Sub
Private Sub Form_Load()
LoadManufacturers
LoadClasses
VerifyCurrentRole
End Sub
Sub VerifyCurrentRole()
If frmMain.CurrentUserRoleID = 1 Then
MsgBox "The current user does not have permission to add or modify vehicles information", vbInformation, "Information"
btnCreate.Enabled = False
End If
End Sub
Sub LoadManufacturers()
ExecuteSQL "Select * from Brand order by Brand_Name asc"
cmbManufacturer.Clear
While Not rs.EOF
cmbManufacturer.AddItem (rs.Fields!Brand_Name)
rs.MoveNext
Wend
End Sub
Sub LoadClasses()
ExecuteSQL "Select * from Class"
cmbClass.Clear
While Not rs.EOF
cmbClass.AddItem (rs.Fields!Class_Name)
rs.MoveNext
Wend
End Sub
Private Sub txtLength_GotFocus()
If txtLength.Text <> "" Then
txtLength.Text = Replace(txtLength.Text, " mm", "")
txtLength.Text = FormatNumber(txtLength.Text, 0, vbFalse, vbFalse, vbFalse)
txtLength.MaxLength = 6
End If
End Sub
Private Sub txtLength_KeyPress(KeyAscii As Integer)
VerifyChar KeyAscii
End Sub
Public Sub txtLength_LostFocus()
txtLength.MaxLength = 10
txtLength.Text = Format(txtLength.Text, "##,### mm")
End Sub
Private Sub txtPrice_GotFocus()
If txtPrice.Text <> "" Then txtPrice.Text = Replace(FormatNumber(txtPrice.Text, 0), ",", "")
End Sub
Private Sub txtPrice_KeyPress(KeyAscii As Integer)
VerifyChar KeyAscii
End Sub
Public Sub txtPrice_LostFocus()
txtPrice.Text = Format(txtPrice.Text, "$#,###")
End Sub
Private Sub txtQuantity_Click()
txtQuantity.MaxLength = 6
End Sub
Private Sub txtQuantity_GotFocus()
If txtQuantity.Text <> "" Then txtQuantity.Text = Replace(FormatNumber(txtQuantity.Text, 0), ",", "")
End Sub
Private Sub txtQuantity_KeyPress(KeyAscii As Integer)
VerifyChar KeyAscii
End Sub
Public Sub txtQuantity_LostFocus()
If Len(txtQuantity) Mod 3 = 0 Then txtQuantity.MaxLength = 7
txtQuantity.Text = Format(txtQuantity.Text, "#,##0")
End Sub
Private Sub txtWidth_GotFocus()
If txtWidth.Text <> "" Then
txtWidth.Text = Replace(txtWidth.Text, " mm", "")
txtWidth.Text = Format(txtWidth.Text, "")
txtWidth.MaxLength = 6
End If
End Sub
Private Sub txtWidth_KeyPress(KeyAscii As Integer)
VerifyChar KeyAscii
End Sub
Sub VerifyChar(KeyAscii As Integer)
If Not IsNumeric(Chr(KeyAscii)) And Not KeyAscii = 8 Then
KeyAscii = 0
MsgBox "Enter only numeric characters!", vbInformation, "Information"
End If
End Sub
Public Sub txtWidth_LostFocus()
txtWidth.MaxLength = 10
txtWidth.Text = Format(txtWidth.Text, "##,### mm")
End Sub
Private Sub txtYear_KeyPress(KeyAscii As Integer)
If Not IsNumeric(Chr(KeyAscii)) And Not KeyAscii = 8 Then
KeyAscii = 0
MsgBox "Enter only numeric characters!", vbInformation, "Information"
End If
If Len(txtYear) = 4 And KeyAscii <> 8 Then
KeyAscii = 0
MsgBox "Enter a valid year of 4 characters"
End If
End Sub