Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

How to Split an array element in half - VB.Net?

I am trying to split an array into bits for example.

customername(0) = John Collins - i want to split that so that

customerFname(0) = John and customerLname = Collins

I can find plenty of examples of how to split strings into an array but no suggestions of how to split an array into another array.

Can someone help me with this?

3 Answers

Relevance
  • Terry
    Lv 4
    1 decade ago
    Favorite Answer

    Dim i As Integer = 0

    Dim fnames As String()

    Dim lnames As String()

    ' Loop through each line in array returned by ReadAllLines

    Dim line As String

    For Each line In File.ReadAllLines("example.txt")

    ' Split line on blank space

    Dim parts As String() = line.Split(New Char() {" "c})

    'Store first and last name separately in two arrays

    fnames(i) = parts(0)

    lnames(i) = parts(1)

    i += 1

    Next line

  • 1 decade ago

    Dim inputname As Array = {"John Collins"}

    Dim tempName As String = CStr(inputname(0))

    Dim fname As String = tempName.Substring(0, tempName.IndexOf(" "))

    Dim lname As String = tempName.Substring(tempName.IndexOf(" ") + 1, Len(tempName) - tempName.IndexOf(" "))

  • 1 decade ago

    Dim something

    something = split(customername(0), " ")

    something(0)=first part

    something(1)=second part

    something(2)= third part

    or if multiplys....

    Dim MMM as integer

    for mmm = lbound(something) to ubound(something)

    textbox.text &=something(mmm) & vbcrlf

    next

Still have questions? Get your answers by asking now.