ExamVeda
Login
Home
This question belongs to Computer Science Visual Basic
Visual Basic
?

What will contain in txtFirst after the following Visual Basic code is executed?

strName = "Penny Swanson"
txtFirst.Text = strName.Remove(5)

Answer & Solution
Correct Answer: Option A
The Remove method in Visual Basic removes a specified number of characters from a string starting from the beginning. In this code snippet, strName is assigned the value "Penny Swanson". Then, the Remove method is used to remove characters from the beginning of strName.

In the expression strName.Remove(5), it removes characters starting from index 0 up to (but not including) index 5. So, it removes the characters " Swans" from "Penny Swanson", leaving "Penny". Therefore, after execution, txtFirst.Text will contain "Penny".
Examveda
Question posted by Examveda
Community

Join the Discussion

1 Comment
Cyrus Khan
Cyrus Khan 2 years ago
please review the answer i think the right answer will be D