Results 1 to 4 of 4

Thread: split function

  1. #1

    Thread Starter
    Hyperactive Member schuurke28's Avatar
    Join Date
    Feb 2001
    Posts
    402

    split function

    how can i get the result of the split function in a variable?
    i.e.:
    Private Sub Form_Load()
    Dim testje(10)
    Dim mystring(10) As String
    Dim i
    i = 0
    mystring(0) = "12,222,+,44,121"
    For i = 0 To 4
    testje(i) = Split(mystring(0), Chr(44))
    Next i
    End Sub

    what am i doing wrong, testje(i) is not being filled..

  2. #2
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    You have to declare a dynamic array for use with split :

    VB Code:
    1. Dim myStrArray() As String
    2. myStrArray = Split(...)
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  3. #3
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    Dim vntarray as variant
    vntarray = Split(data,",")
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  4. #4
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    Originally posted by Cander
    Dim vntarray as variant
    vntarray = Split(data,",")
    Don't use variants!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width