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
Please solve it
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Satyapriya NayakRank #47 · 31.5K reputationPosted Sep 25, 2011, 10:22 AM EDT
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
VulpesRank #55 · 29.2K reputationPosted Sep 26, 2011, 7:10 AM EDT