View Single Post
 
Old 11-27-2013, 10:20 AM
BobBridges's Avatar
BobBridges BobBridges is offline Windows 7 64bit Office 2010 32bit
Expert
 
Join Date: May 2013
Location: USA
Posts: 700
BobBridges has a spectacular aura aboutBobBridges has a spectacular aura about
Default

(Further explanation:) Omaha, Paul included an Exit statement, which is correct if you want to stop once you find "the" value with the slash in it. My version assumes there are multiple values you want to save, and keeps looking through the whole array.

As for the starting point of the array, that depends on how you defined the array. What Paul's saying is that if you define an array like this:
Code:
Dim splitslash(10)
...then VBA will define splitslash with 11 entries running from splitslash(0) to splitslash(10). I'm used to programming in other languages that assume 1 as the bottom entry, so I keep forgetting how VBA does it; to avoid the uncertainty I usually specify both limits, like this:
Code:
Dim splitslash(0 to 10)
...or "1 to 10" or "5 to 23" or whatever suits my purpose.

But no matter what you specified when you defined the array, you can always have your program use the LBound function, which mirrors UBound:
Code:
For i = LBound(splitslash) To UBound(splitslash)
Reply With Quote