![]() |
|
#1
|
|||
|
|||
|
Is there a mistake/typo in the help file here:
Split function (Visual Basic for Applications) | Microsoft Docs Should "arrSplitStrings1()" and "arrSplitStrings2()" not be declared as Strings rather than Variants? Code:
Sub Demo2()
Dim strFull As String
Dim arrSplitStrings1() As Variant
Dim arrSplitStrings2() As Variant
Dim str1 As String, str2 As String, str3 As String
Dim i As Long
' String that will be used:
strFull = "Some - Old - Hags - Can - Always - Hide - Their - Old - Age"
arrSplitStrings1 = Split(strFull, "-")
arrSplitStrings2 = Split(strFull, " - ")
str1 = arrSplitStrings2(3) ' str1 = "Can".
str2 = Split(strFull, " - ")(3) ' str2 = "Can".
For i = LBound(arrSplitStrings2, 1) To UBound(arrSplitStrings2, 1)
If InStr(1, arrSplitStrings2(i), "Can", vbTextCompare) > 0 Then
str3 = arrSplitStrings2(i)
Exit For
End If
Next i
End Sub
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Replace " in string sent to output file
|
gedinfo2020 | Word VBA | 3 | 02-27-2020 02:30 PM |
| "Split apart page break and paragraph mark" setting | harry | Word | 10 | 12-18-2019 07:08 PM |
Keyboard toggle for switching between two split "screens" in Word 2010
|
BAEngelTranslations | Word | 4 | 10-26-2015 04:44 AM |
When Outlook starts, a warning box "String was not recognized as a valide datetime"
|
twormington | Outlook | 4 | 02-03-2014 11:01 PM |
Macro VBA "Save as" with bookmarks in file name string
|
Dom37 | Word VBA | 2 | 10-31-2011 03:28 AM |