Dear friends,
In one of my interview i was asked this question.
I have a string as
Cognizant Technology Services
I want to get the output as
CTS
How to get it
Please give me the solution
thanks
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Satyapriya NayakPosted Sep 25, 2011, 2:22 PM
You can do it in two ways using Mid and Substring keyword.
Mid way:-
Dim x As String
Dim x1 As String
Dim x2 As String
Dim x3 As String
Dim x4 As String
x = "Cognizant Technology Services"
x1 = Mid(x, 1, 1)
x2 = Mid(x, 11, 1)
x3 = Mid(x, 22, 1)
x4 = x1 + x2 + x3
MsgBox(x4)
Substring way:
Dim y As String
Dim y1 As String
Dim y2 As String
Dim y3 As String
Dim y4 As String
y = "Cognizant Technology Services"
y1 = y.Substring(0, 1)
y2 = y.Substring(10, 1)
y3 = y.Substring(21, 1)
y4 = y1 + y2 + y3
MsgBox(y4)
Thanks
VulpesPosted Sep 26, 2011, 11:10 AM