Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Finding out the length of an array created using Split()

Posted on 2004-08-15
2
Medium Priority
?
1,440 Views
Last Modified: 2013-12-25
Hi,

I have got a string which has a list of filenames in it separated by commas, and I have split the string into an array using the Split() function in VB6. As it happens, the string is filled with the list at run time, so I don't actually know how many items the array will have in it. Here is my code so far:

Dim thearray
Dim somestring As String
somestring = "DSC00000.JPG,DSC00001.JPG,DSC00002.JPG"
'The above line isn't actually in the code, because if it was I wouldn't have a problem. Instead, the above line would be replaced with a chunk of code to open a text file and get the contents and put them in the string.
thearray = Split(somestring, ",")

I need a way of finding out how many items are inside the array, so that I can write a loop that iterates through the array and uses each individual filename for a purpose. This should be quite a simple question to answer, and any help would really be appreciated.

Thanks
0
Comment
Question by:alexsilcock
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 200 total points
ID: 11805493
Private Sub Command1_Click()
    Dim thearray As Variant
    Dim somestring As String
    Dim i As Integer
   
    somestring = "DSC00000.JPG,DSC00001.JPG,DSC00002.JPG"
    thearray = Split(somestring, ",")

    For i = LBound(thearray) To UBound(thearray)
        Debug.Print thearray(i)
    Next i
End Sub
0
 
LVL 23

Expert Comment

by:Ioannis Paraskevopoulos
ID: 11807847
NumOfStrings=Ubound(thearray)+1
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question