Advertisement
Guest User

Untitled

a guest
Feb 6th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. 'Is the character illegal? If so replace it in workingName
  2. If IsError(Application.Match(Mid(inputName, i, 1), validchars, 0)) Then
  3.  
  4. 'Detect whether the first character in workingName is a number.
  5. Dim numbers() As Variant
  6. numbers = Array("1", "2", "3", "4", "5", "6", "7", "8", "9", "0")
  7.  
  8. If Not IsError(Application.Match(Mid(workingName, 1, 1), numbers, 0)) Then
  9.  
  10. If Not IsNumeric(Left(workingName,1)) Then
  11.  
  12. Public Function ContainsAny(ByVal string_source As String, ByVal caseSensitive As Boolean, ParamArray find_strings() As Variant) As Boolean
  13.  
  14. Dim find As String, i As Integer, found As Boolean
  15.  
  16. For i = LBound(find_strings) To UBound(find_strings)
  17.  
  18. find = CStr(find_strings(i))
  19. found = Contains(string_source, find, caseSensitive)
  20.  
  21. If found Then Exit For
  22. Next
  23.  
  24. ContainsAny = found
  25.  
  26. End Function
  27.  
  28. If Not ContainsAny(Mid(inputName,i,1), False, "_", _
  29. "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", _
  30. "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", _
  31. "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z") _
  32. Then
  33. 'character is illegal
  34. End If
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement