Commits

Christian Specht committed f40839a

String_Contains

Comments (0)

Files changed (3)

 Receives a complete path, returns only the file name.
 - **`Path_GetFileNameWithoutExtension`**  
 Receives a complete path, returns only the file name without extension.
+- **`String_Contains`**  
+Returns `True` if the second parameter occurs within the first parameter.
 - **`String_EndsWith`**  
 Returns `True` if the second parameter matches the end of the first parameter.
 - **`String_Format`**  

vba-helpers-tests.bas

     
 End Sub
 
+Public Sub String_Contains_ContainsString_ReturnsTrue()
+
+    Assert.IsTrue String_Contains("abc", "ab")
+    
+End Sub
+
+Public Sub String_Contains_DoesNotContainString_ReturnsFalse()
+
+    Assert.IsFalse String_Contains("abc", "ac")
+    
+End Sub
+
 Public Sub String_EndsWith_EndMatchesSecondString_ReturnsTrue()
 
     Assert.IsTrue String_EndsWith("abc", "bc")
 '# VBA Helpers
 '# A collection of useful VBA functions
 '#
-'# Version 20120831.010217
+'# Version 20120831.210207
 '# (the version number is just the current date/time)
 '#
 '# Copyright (c) 2012 Christian Specht
     
 End Function
 
+Public Function String_Contains(ByVal main As String, ByVal value As String) As Boolean
+    'Returns `True` if the second parameter occurs within the first parameter.
+    
+    String_Contains = (InStr(1, main, value) > 0)
+    
+End Function
+
 Public Function String_EndsWith(ByVal main As String, ByVal value As String) As Boolean
     'Returns `True` if the second parameter matches the end of the first parameter.