• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 256
  • Last Modified:

Name swap

I want to swap Cust2 to be Cust1 only if "|" is not blank.

plse see sample

Cust1                 Cust2
jim johnson      | Tim smith | jim johnson
David Williams | Mike Rodriguez |
Sam Red           | Mark Green | Sam Red

result like this

Tim smith | jim johnson
David Williams | Mike Rodriguez
Mark Green | Sam Red
1 Solution
Neil RussellTechnical Development LeadCommented:
Is this a single string expression?
HainKurtSr. System AnalystCommented:
what does this mean? "only if "|" is not blank"
Dim Names as String() = "jim johnson      | Tim smith | jim johnson ".Split("|")
For I as Integer = 0 to Names.Length - 1
      Names(i) = Names(i).Trim()
Dim NewName as string
If Names.Length >2
   If Names(0) = Names(2) Then
      NewName = Names(1) & "|" & Names(0)
   End If
End If
käµfm³d 👽Commented:
You haven't really specified the context of where this replace is to take place.  Are you reading in value from a file and outputting the results after the swap? Are you replacing text in the code window? Are you swapping columns of text inside a control?

Please elaborate.  :)

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now