-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathModSP.bas
618 lines (583 loc) · 19.5 KB
/
ModSP.bas
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
Rem Attribute VBA_ModuleType=VBAModule
Option Explicit
Option VBASupport 1
' This program is free software: you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation, either version 3 of the License, or
' (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with this program. If not, see <http://www.gnu.org/licenses/>.
'@file - ModSP.bas
Public Function ProCheckDate(Opt As String, ColName As String, i_intRowCount As Integer) As Boolean
Dim curCol As Integer
Dim curRow As Integer
Dim oSheet As Object
Dim oCell As Object
If Opt = "P" Then
oSheet = ShPurchase
Else
oSheet = ShSales
End If
curCol = GetColIndex(oSheet, ColName)
For curRow = 1 To i_intRowCount - 1
oCell = oSheet.getCellByPosition(curCol, curRow)
'oCell.String = Format(oCell.String, "DD-MM-YYYY")
If ValidateDate(oCell.String) = False Then
MsgBox "Invalid Date [" & oCell.String & "] in cell " & oCell.AbsoluteName & "." & vbCRLF & "You have to enter date in DD-MM-YYYY format."
SelectObject(oCell)
ProCheckDate = False
Exit Function
End If
Next curRow
ProCheckDate = True
End Function
Public Function ProCheckAmount(Opt As String, PrevCell As String,ColName As String, i_intRowCount As Double) As Boolean
Dim oSheet As Object
Dim oCell As Object
Dim l_intCell As Double
Dim l_intPrev As Double
Dim curRow As Integer
Dim curCol As Integer
If Opt = "P" Then
oSheet = ShPurchase
Else
oSheet = ShSales
End If
For curRow = 1 To i_intRowCount - 1
curCol = GetColIndex(oSheet, ColName)
oCell = oSheet.getCellByPosition(curCol, curRow)
l_intCell = CDbl(oCell.String)
curCol = GetColIndex(oSheet, PrevCell)
oCell = oSheet.getCellByPosition(curCol, curRow)
l_intPrev = CDbl(oCell.String)
If l_intCell > l_intPrev Then
SelectObject(oCell)
ProCheckAmount = False
Exit Function
End If
Next curRow
ProCheckAmount = True
End Function
Public Sub RemoveSpace(Opt As String, cell As String, i_intRowCount As Double)
Dim oSheet As Object
Dim oCell As Object
Dim curRow As Integer
Dim curCol As Integer
If Opt = "P" Then
oSheet = ShPurchase
Else
oSheet = ShSales
End If
'Range(cell).Select
For curRow = 1 To i_intRowCount - 1
oCell = oSheet.getCellByPosition(curCol, curRow)
oCell.String = Trim(oCell.String)
Next curRow
End Sub
Public Function ProCheckLength(opt As String, ColName As String, i_intRowCount As Double, i_lngLen As Long, Cond As String) As Boolean
Dim curCol As Integer
Dim curRow As Integer
Dim oSheet As Object
Dim oCell As Object
If Opt = "P" Then
oSheet = ShPurchase
Else
oSheet = ShSales
End If
curCol = GetColIndex(oSheet, ColName)
For curRow = 1 To i_intRowCount - 1
oCell = oSheet.getCellByPosition(curCol,curRow)
If Cond = "Equal" Then
If Len(oCell.String) <> i_lngLen Then
MsgBox "Value [" & oCell.String & "] in cell " & oCell.AbsoluteName & " Should be of Length" & i_lngLen
ProCheckLength = False
SelectObject(oCell)
Exit Function
End If
ElseIf Cond = "Less" Then
If Len(oCell.String) > i_lngLen Then
MsgBox "Value [" & oCell.String & "] in cell " & oCell.AbsoluteName & " Exceeds Maximum Length" & i_lngLen
ProCheckLength = False
SelectObject(oCell)
Exit Function
End If
End If
Next curRow
ProCheckLength = True
End Function
Public Function ProCheckNumeric(opt As String, ColName As String, i_intRowCount As Double) As Boolean
Dim curRow As Integer
Dim curCol As Integer
Dim oSheet As Object
Dim oCell As Object
If Opt = "P" Then
oSheet = ShPurchase
Else
oSheet = ShSales
End If
curCol = GetColIndex(oSheet, ColName)
For curRow = 1 To i_intRowCount - 1
oCell = oSheet.getCellByPosition(curCol,curRow)
If IsNumeric(oCell.String) = False Or oCell.String = "" Then
MsgBox " Non Numeric Value [" & oCell.String & "] Found in cell " & oCell.AbsoluteName
ProCheckNumeric = False
SelectObject(oCell)
Exit Function
ElseIf Trim(oCell.String) = "" Then
MsgBox " Null Value [" & oCell.String & "] Found in cell " & oCell.AbsoluteName
ProCheckNumeric = False
SelectObject(oCell)
Exit Function
ElseIf InStr(Trim(oCell.String), ",") > 0 Then
MsgBox " Non Numeric Value, Remove Comma(,) [" & oCell.String & "] Found in cell " & oCell.AbsoluteName
ProCheckNumeric = False
SelectObject(oCell)
Exit Function
ElseIf ColName = "C" Then
If InStr(Trim(oCell.String), ".") > 0 Then
MsgBox "Non Numeric Value, Remove Dot(.)"
ProCheckNumeric = False
SelectObject(oCell)
Exit Function
End If
ElseIf oCell.String < 0 Then
MsgBox "Value should not be less than zero [" & oCell.String & "] Found in cell " & oCell.AbsoluteName
ProCheckNumeric = False
SelectObject(oCell)
Exit Function
End If
If CDbl(oCell.String) = "0" Then
oCell.String = "0"
Else
If ColName <> "C" Then
oCell.String = Replace(LTrim(Replace(oCell.String, "0", " ")), " ", "0")
oCell.String = Round(oCell.String, 2)
End If
End If
Next curRow
ProCheckNumeric = True
End Function
'This Function is used to Replace < ,' and & which creates error duing uploading
Public Sub ValidateString(Opt As String, ColName As String, i_intRowCount As Integer)
Dim oSheet as Object
Dim oCell as Object
Dim curCol as Integer
Dim curRow As Integer
If Opt = "P" Then
oSheet = ShPurchase
Else
oSheet = ShSales
End If
curCol = GetColIndex(oSheet, ColName)
For curRow = 1 To i_intRowCount - 1
oCell = oSheet.getCellByPosition(curCol,curRow)
If InStr(oCell.String, "<") <> 0 Then
oCell.String = Replace(oCell.String, "<", " ")
ElseIf InStr(oCell.String, "!") <> 0 Then
oCell.String = Replace(oCell.String, "!", " ")
ElseIf InStr(oCell.String, "@") <> 0 Then
oCell.String = Replace(oCell.String, "@", " ")
ElseIf InStr(oCell.String, "#") <> 0 Then
oCell.String = Replace(oCell.String, "#", " ")
ElseIf InStr(oCell.String, "$") <> 0 Then
oCell.String = Replace(oCell.String, "$", " ")
ElseIf InStr(oCell.String, "%") <> 0 Then
oCell.String = Replace(oCell.String, "%", " ")
ElseIf InStr(oCell.String, "^") <> 0 Then
oCell.String = Replace(oCell.String, "^", " ")
ElseIf InStr(oCell.String, "*") <> 0 Then
oCell.String = Replace(oCell.String, "*", " ")
ElseIf InStr(oCell.String, "(") <> 0 Then
oCell.String = Replace(oCell.String, "(", " ")
ElseIf InStr(oCell.String, ")") <> 0 Then
oCell.String = Replace(oCell.String, ")", " ")
ElseIf InStr(oCell.String, "_") <> 0 Then
oCell.String = Replace(oCell.String, "_", " ")
ElseIf InStr(oCell.String, "-") <> 0 Then
oCell.String = Replace(oCell.String, "-", " ")
ElseIf InStr(oCell.String, "=") <> 0 Then
oCell.String = Replace(oCell.String, "=", " ")
ElseIf InStr(oCell.String, "+") <> 0 Then
oCell.String = Replace(oCell.String, "+", " ")
ElseIf InStr(oCell.String, "\") <> 0 Then
oCell.String = Replace(oCell.String, "\", " ")
ElseIf InStr(oCell.String, "{") <> 0 Then
oCell.String = Replace(oCell.String, "{", " ")
ElseIf InStr(oCell.String, "}") <> 0 Then
oCell.String = Replace(oCell.String, "}", " ")
ElseIf InStr(oCell.String, "[") <> 0 Then
oCell.String = Replace(oCell.String, "[", " ")
ElseIf InStr(oCell.String, "]") <> 0 Then
oCell.String = Replace(oCell.String, "]", " ")
ElseIf InStr(oCell.String, ":") <> 0 Then
oCell.String = Replace(oCell.String, ":", " ")
ElseIf InStr(oCell.String, ";") <> 0 Then
oCell.String = Replace(oCell.String, ";", " ")
ElseIf InStr(oCell.String, ",") <> 0 Then
oCell.String = Replace(oCell.String, ",", " ")
ElseIf InStr(oCell.String, ".") <> 0 Then
oCell.String = Replace(oCell.String, ".", " ")
ElseIf InStr(oCell.String, "&") <> 0 Then
oCell.String = Replace(oCell.String, "&", " ")
ElseIf InStr(oCell.String, "'") <> 0 Then
oCell.String = Replace(oCell.String, "'", " ")
ElseIf InStr(oCell.String, """") <> 0 Then
oCell.String = Replace(oCell.String, """", " ")
ElseIf InStr(oCell.String, ">") <> 0 Then
oCell.String = Replace(oCell.String, ">", " ")
ElseIf InStr(oCell.String, "|") <> 0 Then
oCell.String = Replace(oCell.String, "|", " ")
ElseIf InStr(oCell.String, "/") <> 0 Then
oCell.String = Replace(oCell.String, "/", " ")
End If
oCell.String = Replace(Replace(oCell.String, vbLf, " "), vbCr, " ")
oCell.String = Replace(oCell.String, " ", "")
Next curRow
End Sub
'Added------------------------------------------------------------------------------------------------------------------
Public Sub ValidateString1(Opt As String, ColName As String, i_intRowCount As Double)
Dim oSheet As Object
Dim oCell As Object
Dim curRow As Integer
Dim curCol As Integer
If Opt = "P" Then
oSheet = ShPurchase
Else
oSheet = ShSales
End If
curCol = GetColIndex(oSheet, ColName)
For curRow = 1 To i_intRowCount - 1
oCell = oSheet.getCellByPosition(curCol, curRow)
If InStr(oCell.String, "!") <> 0 Then
oCell.String = Replace(oCell.String, "!", " ")
ElseIf InStr(oCell.String, "#") <> 0 Then
oCell.String = Replace(oCell.String, "#", " ")
ElseIf InStr(oCell.String, "$") <> 0 Then
oCell.String = Replace(oCell.String, "$", " ")
ElseIf InStr(oCell.String, "%") <> 0 Then
oCell.String = Replace(oCell.String, "%", " ")
ElseIf InStr(oCell.String, "^") <> 0 Then
oCell.String = Replace(oCell.String, "^", " ")
ElseIf InStr(oCell.String, "*") <> 0 Then
oCell.String = Replace(oCell.String, "*", " ")
ElseIf InStr(oCell.String, "=") <> 0 Then
oCell.String = Replace(oCell.String, "=", " ")
ElseIf InStr(oCell.String, "+") <> 0 Then
oCell.String = Replace(oCell.String, "+", " ")
ElseIf InStr(oCell.String, "|") <> 0 Then
oCell.String = Replace(oCell.String, "|", " ")
ElseIf InStr(oCell.String, "\") <> 0 Then
oCell.String = Replace(oCell.String, "\", " ")
ElseIf InStr(oCell.String, "{") <> 0 Then
oCell.String = Replace(oCell.String, "{", " ")
ElseIf InStr(oCell.String, "}") <> 0 Then
oCell.String = Replace(oCell.String, "}", " ")
ElseIf InStr(oCell.String, "[") <> 0 Then
oCell.String = Replace(oCell.String, "[", " ")
ElseIf InStr(oCell.String, "]") <> 0 Then
oCell.String = Replace(oCell.String, "]", " ")
ElseIf InStr(oCell.String, "'") <> 0 Then
oCell.String = Replace(oCell.String, "'", " ")
ElseIf InStr(oCell.String, """") <> 0 Then
oCell.String = Replace(oCell.String, """", " ")
ElseIf InStr(oCell.String, ",") <> 0 Then
oCell.String = Replace(oCell.String, ",", " ")
ElseIf InStr(oCell.String, "<") <> 0 Then
oCell.String = Replace(oCell.String, "<", " ")
End If
oCell.String = Replace(Replace(oCell.String, vbLf, " "), vbCr, " ")
Next curRow
End Sub
'------------------------------------------------------------------------------------------------------------------
Sub proValidate_Purchase()
Dim oRange as Object
Dim l_intRowCount as Integer
oRange = FindUsedRange(ShPurchase)
l_intRowCount = oRange.Rows.Count
If l_intRowCount = 1 Then
MsgBox "No Data Entered", vbInformation + vbOKOnly
Exit Sub
End If
If ProCheckDuplicate("P", l_intRowCount) = False Then
Exit Sub
End If
ValidateString "P", "A", l_intRowCount
RemoveSpace "P", "A", l_intRowCount
If ProCheckMandatory("P", "A", l_intRowCount) = False Then
Exit Sub
End If
If ProCheckLength("P", "A", l_intRowCount, 25, "Less") = False Then
Exit Sub
End If
'ProRound "P", "B", l_intRowCount
If ProCheckDate("P", "B", l_intRowCount) = False Then
Exit Sub
End If
RemoveSpace "P", "C", l_intRowCount
If ProCheckNumeric("P", "C", l_intRowCount) = False Then
Exit Sub
End If
If ProCheckLength("P", "C", l_intRowCount, 11, "Equal") = False Then
Exit Sub
End If
ValidateString1 "P", "D", l_intRowCount
If ProCheckURMandatory("P", "D", l_intRowCount) = False Then
Exit Sub
End If
If ProCheckLength("P", "D", l_intRowCount, 150, "Less") = False Then
Exit Sub
End If
ValidateString1 "P", "E", l_intRowCount
If ProCheckURMandatory("P", "E", l_intRowCount) = False Then
Exit Sub
End If
If ProCheckLength("P", "E", l_intRowCount, 200, "Less") = False Then
Exit Sub
End If
RemoveSpace "P", "F", l_intRowCount
If ProCheckNumeric("P", "F", l_intRowCount) = False Then
Exit Sub
End If
If ProCheckLength("P", "F", l_intRowCount, 17, "Less") = False Then
Exit Sub
End If
RemoveSpace "P", "G", l_intRowCount
If ProCheckNumeric("P", "G", l_intRowCount) = False Then
Exit Sub
End If
If ProCheckLength("P", "G", l_intRowCount, 17, "Less") = False Then
Exit Sub
End If
If ProCheckAmount("P", "F", "G", l_intRowCount) = False Then
MsgBox "Vat Amount Greater than Value of Goods"
Exit Sub
End If
RemoveSpace "P", "H", l_intRowCount
If ProCheckNumeric("P", "H", l_intRowCount) = False Then
Exit Sub
End If
If ProCheckLength("P", "H", l_intRowCount, 17, "Less") = False Then
Exit Sub
End If
If ProCheckAmount("P", "F", "H", l_intRowCount) = False Then
MsgBox "Cess Amount Greater than Value of Goods"
Exit Sub
End If
GenerateTxt "P"
End Sub
Sub proValidate_Sales()
Dim oRange as Object
Dim l_intRowCount as Integer
Dim oSheet As Object
Dim oCell As Object
oRange = FindUsedRange(ShSales)
l_intRowCount = oRange.Rows.Count
If l_intRowCount = 1 Then
MsgBox "No Data Entered", vbInformation + vbOKOnly
Exit Sub
End If
If ProCheckDuplicate("S", l_intRowCount) = False Then
Exit Sub
End If
ValidateString "S", "A", l_intRowCount
RemoveSpace "S", "A", l_intRowCount
If ProCheckMandatory("S", "A", l_intRowCount) = False Then
Exit Sub
End If
If ProCheckLength("S", "A", l_intRowCount, 25, "Less") = False Then
Exit Sub
End If
If ProCheckDate("S", "B", l_intRowCount) = False Then
Exit Sub
End If
RemoveSpace "S", "C", l_intRowCount
If ProCheckNumeric("S", "C", l_intRowCount) = False Then
Exit Sub
End If
If ProCheckLength("S", "C", l_intRowCount, 11, "Equal") = False Then
Exit Sub
End If
ValidateString1 "S", "D", l_intRowCount
If ProCheckURMandatory("S", "D", l_intRowCount) = False Then
Exit Sub
End If
If ProCheckLength("S", "D", l_intRowCount, 150, "Less") = False Then
Exit Sub
End If
ValidateString1 "S", "E", l_intRowCount
If ProCheckURMandatory("S", "E", l_intRowCount) = False Then
Exit Sub
End If
If ProCheckLength("S", "E", l_intRowCount, 200, "Less") = False Then
Exit Sub
End If
RemoveSpace "S", "F", l_intRowCount
If ProCheckNumeric("S", "F", l_intRowCount) = False Then
Exit Sub
End If
If ProCheckLength("S", "F", l_intRowCount, 17, "Less") = False Then
Exit Sub
End If
RemoveSpace "S", "G", l_intRowCount
If ProCheckNumeric("S", "G", l_intRowCount) = False Then
Exit Sub
End If
If ProCheckLength("S", "G", l_intRowCount, 17, "Less") = False Then
Exit Sub
End If
If ProCheckAmount("S", "F", "G", l_intRowCount) = False Then
MsgBox "Vat Amount Greater than Invoice Amount"
Exit Sub
End If
RemoveSpace "S", "H", l_intRowCount
If ProCheckNumeric("S", "H", l_intRowCount) = False Then
Exit Sub
End If
If ProCheckLength("S", "H", l_intRowCount, 17, "Less") = False Then
Exit Sub
End If
If ProCheckAmount("S", "F", "H", l_intRowCount) = False Then
MsgBox "Cess Amount Greater than Invoice Amount"
Exit Sub
End If
GenerateTxt "S"
End Sub
Public Function ProCheckMandatory(Opt As String, ColName As String, i_intRowCount As Integer) As Boolean
Dim curRow As Integer
Dim curCol As Integer
Dim oSheet As Object
Dim oCell As Object
If Opt = "P" Then
oSheet = ShPurchase
Else
oSheet = ShSales
End If
curCol = GetColIndex(oSheet, ColName)
'Check if any of the cells are empty and if so return false
For curRow = 1 To i_intRowCount - 1
oCell = oSheet.getCellByPosition(curCol, curRow)
If oCell.String = "" Or Trim(oCell.String) = "0" Then
MsgBox "Mandatory Information Missing or Value is zero [" & oCell.String & "] in cell " & oCell.AbsoluteName
SelectObject(oCell)
ProCheckMandatory = False
Exit Function
End If
Next curRow
ProCheckMandatory = True
End Function
'Added---------------------------------------------------------------------------------------------------------------
Public Function ProCheckURMandatory(Opt As String,ColName As String, i_intRowCount As Double) As Boolean
Dim oSheet As Object
Dim oCell As Object
Dim curCol As Integer
Dim curRow As Integer
If Opt = "P" Then
oSheet = ShPurchase
Else
oSheet = ShSales
End If
For curRow = 1 To i_intRowCount - 1
curCol = GetColIndex(oSheet, "C")
oCell = oSheet.getCellByPosition(curCol,curRow)
If oCell.String = "88888888888" Or oCell.String = "99999999999" Or Mid(oCell.String, 1, 2) <> "32" Then
curCol = GetColIndex(oSheet, ColName)
oCell = oSheet.getCellByPosition(curCol,curRow)
If Trim(oCell.String) = "" Then
MsgBox "Mandatory Information Missing [" & oCell.String & "] in cell " & oCell.AbsoluteName
ProCheckURMandatory = False
SelectObject(oCell)
Exit Function
End If
End If
Next curRow
ProCheckURMandatory = True
End Function
Public Function ProCheckDuplicate(Opt As String,i_intRowCount As Double) As Boolean
Dim l_dblURCount As Double
Dim l_dblISCount As Double
Dim curCol As Integer
Dim oSheet As Object
Dim oCell As Object
Dim curRow As Integer
dim ColName As String
ColName = "C"
l_dblURCount = 0
l_dblISCount = 0
If Opt = "P" Then
oSheet = ShPurchase
Else
oSheet = ShSales
End If
curCol = GetColIndex(oSheet, ColName)
For curRow = 2 To i_intRowCount
oCell = oSheet.getCellByPosition(curCol, curRow)
If Trim(oCell.String) = "99999999999" Then
l_dblURCount = l_dblURCount + 1
ElseIf Trim(oCell.String) = "88888888888" Then
l_dblISCount = l_dblISCount + 1
End If
Next curRow
If l_dblURCount > 1 Then
MsgBox "Only One Entry Should be There for the Unregistered Entry "
ProCheckDuplicate = False
SelectObject(oCell)
Exit Function
End If
If l_dblISCount > 1 Then
MsgBox "Only One Entry Should be There for the InsterState and Export Entry"
ProCheckDuplicate = False
SelectObject(oCell)
Exit Function
End If
ProCheckDuplicate = True
End Function
'----------------------------------------------------------------------------------------------------------------------
Public Function ValidateDate(i_date As String) As Boolean
If Mid(i_date, 3, 1) <> "-" Then
ValidateDate = False
Exit Function
End If
If Mid(i_date, 6, 1) <> "-" Then
ValidateDate = False
Exit Function
End If
If (Val(Mid(i_date, 4, 2)) < 1 Or Val(Mid(i_date, 4, 2)) > 12) Then
ValidateDate = False
Exit Function
End If
'Added-----------------------------------------------------------------------------------------------------------
If (Val(Mid(i_date, 4, 2)) = 1 Or Val(Mid(i_date, 4, 2)) = 3 Or Val(Mid(i_date, 4, 2)) = 5 Or Val(Mid(i_date, 4, 2)) = 7 Or Val(Mid(i_date, 4, 2)) = 8 Or Val(Mid(i_date, 4, 2)) = 10 Or Val(Mid(i_date, 4, 2)) = 12) Then
If (Val(Mid(i_date, 1, 2)) > 31) Then
ValidateDate = False
Exit Function
End If
End If
If (Val(Mid(i_date, 4, 2)) = 4 Or Val(Mid(i_date, 4, 2)) = 6 Or Val(Mid(i_date, 4, 2)) = 9 Or Val(Mid(i_date, 4, 2)) = 11) Then
If (Val(Mid(i_date, 1, 2)) > 30) Then
ValidateDate = False
Exit Function
End If
End If
If (Val(Mid(i_date, 4, 2)) = 2) Then
If (Val(Mid(i_date, 1, 2)) > 29) Then
ValidateDate = False
Exit Function
End If
End If
If (Val(Mid(i_date, 4, 2)) < 1 Or Val(Mid(i_date, 4, 2)) > 12) Then
ValidateDate = False
Exit Function
End If
'------------------------------------------------------------------------------------------------------------
If Val(Mid(i_date, 7, 4)) < 1900 Then
ValidateDate = False
Exit Function
End If
ValidateDate = True
End Function