Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-18-2020, 10:08 PM
John 4 John 4 is offline Mistake in the help file for String "Split Function"? Windows 10 Mistake in the help file for String "Split Function"? Office 2013
Advanced Beginner
Mistake in the help file for String "Split Function"?
 
Join Date: Oct 2019
Posts: 69
John 4 is on a distinguished road
Default Mistake in the help file for String "Split Function"?

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
Reply With Quote
  #2  
Old 11-18-2020, 11:15 PM
macropod's Avatar
macropod macropod is online now Mistake in the help file for String "Split Function"? Windows 10 Mistake in the help file for String "Split Function"? Office 2010
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

It is best not to use variants unless needed, as they require more memory than other data types.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 11-18-2020, 11:42 PM
John 4 John 4 is offline Mistake in the help file for String "Split Function"? Windows 10 Mistake in the help file for String "Split Function"? Office 2013
Advanced Beginner
Mistake in the help file for String "Split Function"?
 
Join Date: Oct 2019
Posts: 69
John 4 is on a distinguished road
Default

Thanks Macropod. But is it not more significant than a matter of efficiency? By declaring them as Variants the macro appears not to work. I get "Runtime error '13': Type mismatch".
Reply With Quote
  #4  
Old 11-19-2020, 12:06 AM
macropod's Avatar
macropod macropod is online now Mistake in the help file for String "Split Function"? Windows 10 Mistake in the help file for String "Split Function"? Office 2010
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

I see what you mean. They should be declared as strings.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 11-19-2020, 02:16 AM
John 4 John 4 is offline Mistake in the help file for String "Split Function"? Windows 10 Mistake in the help file for String "Split Function"? Office 2013
Advanced Beginner
Mistake in the help file for String "Split Function"?
 
Join Date: Oct 2019
Posts: 69
John 4 is on a distinguished road
Default

Hopefully one of you can pass that on to Microsoft for the benefit of other novices like myself. Using that help file as a guide for my own macro, I spent two very frustrating hours trying to figure out what was wrong with my code.

Thank you though for quick replies and for clearing that up for me.

Last edited by John 4; 11-19-2020 at 05:54 AM.
Reply With Quote
  #6  
Old 11-19-2020, 04:48 AM
macropod's Avatar
macropod macropod is online now Mistake in the help file for String "Split Function"? Windows 10 Mistake in the help file for String "Split Function"? Office 2010
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

This forum has no affiliation with Microsoft.

You could make a suggestion for the change at Welcome to Word's Suggestion Box!.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #7  
Old 11-19-2020, 06:02 AM
John 4 John 4 is offline Mistake in the help file for String "Split Function"? Windows 10 Mistake in the help file for String "Split Function"? Office 2013
Advanced Beginner
Mistake in the help file for String "Split Function"?
 
Join Date: Oct 2019
Posts: 69
John 4 is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
This forum has no affiliation with Microsoft.
Thanks Paul. I'm aware of that; I just thought they'd be more likely to listen to someone like you than someone like me. And I still think so

But I'll let them know. My apologies also if my last post seemed angrier than I intended. I've edited it a little to make it less so. Thanks for all your help.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mistake in the help file for String "Split Function"? 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
Mistake in the help file for String "Split Function"? Keyboard toggle for switching between two split "screens" in Word 2010 BAEngelTranslations Word 4 10-26-2015 04:44 AM
Mistake in the help file for String "Split Function"? When Outlook starts, a warning box "String was not recognized as a valide datetime" twormington Outlook 4 02-03-2014 11:01 PM
Mistake in the help file for String "Split Function"? Macro VBA "Save as" with bookmarks in file name string Dom37 Word VBA 2 10-31-2011 03:28 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:12 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft