Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Splitting Names F/M/L and sometimes F/L
#1
Not Solved
I need to split Names that are captured with my QTP script. I need to be able to use FirstName, MiddleName, and LastName independently.
The Issue is, sometimes the MiddleName is missing.
Is there a way to look at the right most characters till the space and call this first name, then look at the left most characters till the space and call this last name?
Reply
#2
Not Solved
Hello there!

Can you please send the sample name you want to Split. or sample code would also helps.

THanks


Thanks,

UFTEnthusiast
Reply
#3
Not Solved
Hi Brian,

No need to look for right most or left characters to handle the situation, Just checking with an If condition would solve your problem. Below is the code I ve written to suit your requirement.

Code:
Function splitNames(str)

splitNames = split(str," ")
  
End Function

strName = splitNames("Suresh Vasu Kondapally")
IF UBound(strName)<2 Then
MsgBox "First Name :"&strName(0)&", Middle Name : Not Entered"&", Last Name :  "&strName(1)
Else
MsgBox "First Name :"&strName(0)&", Middle Name : "&strName(1)&", Last Name :  "&strName(2)
End IF


You can put "/" if you want in the name as you asked F/M/L, in place of space " ". But dont forget to replace that at both the places that is when sending an argument and at split keyword in the function.

Thanks,
Suesh.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  QTP is not identifying table with column names property but its identifing with index Anuradha B 1 2,991 02-12-2015, 04:00 PM
Last Post: Kirill
  How to read Column names of MsAccess Table dineshb 2 2,765 12-07-2009, 08:05 PM
Last Post: dineshb

Forum Jump:


Users browsing this thread: 1 Guest(s)