Hi everybady,

i have faced few Qns in one of i attended interview, please help me out with these below Qns.
1. how to join values without using join function?
2. how to compare values without using String compare function?
3. input is Bangalore, but i need output like this below format, what is function to use and get this outcome
B
A
N
G
A
L
o
R
E
4. Input is "CapGemini" but uotput should be like this "inimeGpaC"
5. Input is
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
Can someone let me know results of this Qns, please. Thanks.

Answer Posted / cnu_thatavarthi

1. how to join values without using join function?

Ans:
Option Explicit
Dim strValue, arrValue,iCount

arrValue = Array("Srinivasulu","Thatavarthi")

For iCount = 0 To UBound(arrValue)

strValue =strValue&" "& arrValue(iCount)

Next

MsgBox strValue

'Actual Output:
---------------------------

---------------------------
Srinivasulu Thatavarthi
---------------------------
OK
---------------------------
2. how to compare values without using String compare function?
Ans:
Option Explicit
Dim strValue

strValue = "Thatavarthi"

If strValue = "Thatavarthi" Then
MsgBox "Both strings are same"
Else
MsgBox "Both strings are not same"
End If

'Expected out Put
---------------------------

---------------------------
Both strings are same
---------------------------
OK
---------------------------
3. input is Bangalore, but i need output like this below format, what is function to use and get this outcome
B
A
N
G
A
L
o
R
E?
Ans:
Option Explicit
Dim strValue,iCount, strNewValue

strValue = Ucase("Bangalore")

For iCount = 1 To Len(strValue)

strNewValue = strNewValue& vbNewLine& Mid(strValue,iCount,1)

Next
MsgBox strNewValue

'Expected Value:
---------------------------

---------------------------


B

A

N

G

A

L

O

R

E
---------------------------
OK
---------------------------
4. Input is "CapGemini" but uotput should be like this "inimeGpaC"
Option Explicit
Dim strValue,iCount, strNewValue

strValue = "CapGemini"

For iCount = Len(strValue) To 1 Step -1

strNewValue = strNewValue& Mid(strValue,iCount,1)

Next

strNewValue = Trim(strNewValue)
MsgBox strNewValue

'Expected value
---------------------------

---------------------------
inimeGpaC
---------------------------
OK
---------------------------
5. Input is
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
Ans:

Option Explicit
Dim iCount,strValue,jcount,arrValue

For iCount = 1 To 5
For jcount = 1 To 5
If iCount = jcount then
strValue = strValue&jcount
Exit For
End IF
Next
arrValue = arrValue&vbNewline& strValue
Next

MsgBox arrValue
'Expected Output
---------------------------

---------------------------


1

12

123

1234

12345
---------------------------
OK
---------------------------

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to access array data?

535


In html file what is an ideal position to include vbscript?

798


how to comvert 120 into one hunderd twenty rupees only and vice varsa

1792


How to make sure that items in a wintree are sorted al?

2345


How to assign a date value to a variable?

583






What is the difference between function and procedure?

561


Sub link() Dim k As Integer Dim rand As Integer Dim URL As String Dim foldernum As Integer Dim folderstring As String Dim filenum As Integer Dim filestring As String k = 1 'for AC Numbers For i = 11 To 40 foldernum = 0 foldernum = 1000 + i folderstring = CStr(foldernum) folderstring = Mid(folderstring, 2, 3) folder = "ac" & folderstring 'folderstring = Sheets(2).Cells(i, 1) ' for Number of Random files For j = 1 To 10 rand = Int(Rnd * (200 - 1) + 1) filenum = 0 filenum = 1000 + rand filestring = CStr(filenum) filestring = Mid(filestring, 2, 3) 'URL = "http://ceobihar.nic.in/PSCDROM/ac" & folderstring & "/i" & folderstring & "0" & filestring & ".pdf" URL = "http://www.elections.tn.gov.in/pdfs/dt1/" & folder & "/" & folder & filestring & ".pdf" ' URL =http://www.wb.nic.in/wbeco/EROLLS/PDF/English/A001/a0010105 .pdf Cells(k, 1) = folderstring Cells(k, 2) = folder Cells(k, 3) = filestring Cells(k, 3) = URL k = k + 1 Next j Next i End Sub plz define it

2227


Which loop is used in case of arrays in the vbscript language?

510


Explain the functionality of vbscript?

526


HOw we can apply web service checkpoint in QTP 9.5? I tried it out with net connection also. But not getting success.

2054


When does ‘on click of button’ event gets triggered in the vbscript language?

532


Set srchobj=Description.Create() srchobj("type").value="text" srchobj("name").value="q" srchobj("html tag").value="input" browser("micclass:=google").Page("micclass:=google").webedit (srchobj).Set "qtp" what's wrong in my code pls tell me ? the above code working fine and i got my result pass,now i am trying to run the program it shows general run time error why?pls help me i am in learning stage ?

1542


Write a function for Instr(). We need to write a function that works as same as Instr(). Code or Even pseudo code is good enough for me.?

2022


how to write codings in QTP using vb script. please help me. i am new to QTP. it is easy or very much tough. please tell me

12858


If else for do while select in vb script?

634