Good morning community,
Can someone help me with the IndexOf method to reverse the name: Don Paul to Paul, D
What have you tried so far?
Dim name As String = "Don Paul" Dim position As Integer = name.IndexOf("P") ' get the position of the first letter in the surname Dim reversed As String = name.Substring(position) + ", " + name.Substring(0, 1) 'join the surname with the first letter of the name
Hope this helps
Mind you if you have different names you want to process it might be better to use the space instead:
Dim name As String = "Don Paul" Dim position As Integer = name.IndexOf(" ") + 1 name = name.Substring(position) & ", " & name.First
i agree tinstaafl; I substituted as I went along. thank a lot wrathness.