Advertisement
Guest User

Untitled

a guest
Mar 21st, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 2.39 KB | None | 0 0
  1.  
  2. 'global variable to store which row the last error has added to
  3. Public SheetName As String
  4. Public Col, Row As Integer
  5.  
  6. Public Function CountRows()
  7.     ' count rows and save as variable
  8.     Rows = 1
  9.    
  10. End Function
  11.  
  12. Public Function StringValidation(ByVal inp As String, ByVal length As String)
  13.    
  14. End Function
  15.  
  16. Public Function DateValidation(ByVal inp As String)
  17.  
  18. End Function
  19.  
  20. Public Function DecimalValidation(ByVal inp As Single)
  21.  
  22. End Function
  23.  
  24. Public Function EmailValidation(ByVal inp As String)
  25.  
  26. End Function
  27.  
  28. Public Function PhoneNumberValidation(ByVal inp As String)
  29.  
  30. End Function
  31.  
  32. Public Function NationalInsuranceValidation(ByVal inp As String)
  33.  
  34. End Function
  35.  
  36. Public Function IntegerValidation(ByVal inp As String, ByVal length As Integer)
  37.  
  38.     If IsNumeric(inp) Then
  39.         IntegerValidation = True
  40.         If Len(inp) > 0 And Len(inp) < 255 Then
  41.             If CInt(inp) > 0 Then
  42.                 IntegerValidation = True
  43.             Else
  44.                 Call AddError("Even another error", Row, Col)
  45.             End If
  46.         Else
  47.             Call AddError("Another Error: ", Row, Col)
  48.         End If
  49.     Else
  50.         Call AddError("Error:", Row, Col)
  51.     End If
  52.     IntegerValidation = False
  53. End Function
  54.  
  55. Sub UserMaster()
  56.     Dim Val As String
  57.     For Col = 1 To 52
  58.         For Row = 2 To 2
  59.             Sheets("Test").Select
  60.             SheetName = "Test"
  61.             Val = Cells(Row, Col)
  62.             Select Case Col
  63.                 Case Is = 2
  64.                     ' Example
  65.                     MsgBox (IntegerValidation(Val, Some_Length))
  66.                 Case Else
  67.             End Select
  68.         Next Row
  69.     Next Col
  70. End Sub
  71.  
  72. Sub ValidateUserInput()
  73.     For Each Sheet In Worksheets
  74.         Select Case Sheet.Name
  75.             Case Is = "User Master"
  76.                 Call UserMaster
  77.             Case Is = "Customer Master"
  78.                 'Call CustomerMaster
  79.             Case Is = "Department Master"
  80.                 'Call DepartmentMaster
  81.             Case Is = "Department User Master"
  82.                 'Call DepartmentUserMaster
  83.             Case Is = "Project Master"
  84.                 'Call ProjectMaster
  85.             Case Else
  86.         End Select
  87.        
  88.     Next Sheet
  89. End Sub
  90.  
  91. Public Sub AddError(ByVal ErrorMsg As String, ByVal Row As String, ByVal Col As String)
  92.     MsgBox (ErrorMsg & "- Row: " & Row & " Col: " + Col)
  93. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement