VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Quick and easy! -- Create an array from a string or a string from an array.

by Big Al (4 Submissions)
Category: String Manipulation
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Wed 23rd August 2000
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Quick and easy! -- Create an array from a string or a string from an array.

Rate Quick and easy! -- Create an array from a string or a string from an array.




   Dim aryTest() As String
   Dim strText As String
   Dim lngCount As Long
   
   strText = "This is a test"
   
   'Create the array
   aryTest = Split(strText)
   
   'You now have a one-dimensional zero-based array with the substrings as the elements
   
   'Print out the array in the Immediate Window
   For lngCount = 0 To UBound(aryTest)
      Debug.Print aryTest(lngCount)
   Next

End Sub

Private Sub Array2String()

   Dim aryTest(4) As String
   Dim strText As String
   
   aryTest(0) = "This"
   aryTest(1) = "is"
   aryTest(2) = "a"
   aryTest(3) = "test"
   
   'Create the string
   strText = Join(aryTest)
   
   'You now have a space-delimited string made up of the elements in your array
   
   'View in the Immediate Window
   Debug.Print strText

End Sub


Download this snippet    Add to My Saved Code

Quick and easy! -- Create an array from a string or a string from an array. Comments

No comments have been posted about Quick and easy! -- Create an array from a string or a string from an array.. Why not be the first to post a comment about Quick and easy! -- Create an array from a string or a string from an array..

Post your comment

Subject:
Message:
0/1000 characters