Tuesday, 23 June 2020

27 - Web Designing Question - 07

Which of the following Visual Basic statement will assign the value "QUICK" from the variable y to the string variable x?

Y= "The QUICK RED FOX JUMPED OVER THE DOG"

(A)    x= Middle (y, 5, 5)

(B)    x= left (Y,5)

(C)    x= Mid (Y,5,5)

(D)   x= Instr (5,y, "QUICK") 


 

Option (A)

There is no function in VBScript of name Middle. So it is wrong

Option (B)

Left(string, no_of_char) is a text function use to extract the chars or string form the left of main string. For example

Left(“Ram Kumar”,3) will return Ram

So it is not a correct answer because we want extract chars from middle.

Option (C)

For extract chars from the middle of a string we use mid() function in VBScript

Mid(string, start, no_of_char)

Here string is the main string from which we want to extract chars

Start is the starting position from which we want to extract chars

No_of_char represent the how many chars we want to extract from the string

Mid(Y,5,5) return “QUICK” because position of Q is 5 and There are five characters in QUICK

So it is the correct Answer

Option (D)

Instr (5,y, "QUICK") is a text function it return the first occurrence of QUICK checking from 5th position so it return 5


No comments:

Post a Comment