You are on page 1of 1

Dim strString As String = "We uphold honor and excellence.

"
1. Mid(Microsoft.VisualBasic.Right(strString, 10),4,5) = ____; Mid("xcellence",4,5) = "llenc"
Parameters Result/datatype Output Value
Right (string, length) String Microsoft.VisualBasic.Right(strString, 10) =
"xcellence"
Mid function (string,start [,length]) Returns the Dim strExample As String = “This is an example.”
characters Dim intResult As Integer
intResult = Mid (strExample, 1, 4) = “This”
'a stand-alone stmt or found at right side of "="
Mid statement (target, start [,length]) Replaces the Mid (strExample, 1, 4) = “That” => “That is an example.”
character ‘found at left side of "=";
2. Mid(strString, InStr(4,strString, "o"), 5) = ____; = Mid(strString, 7, 5) = "old_h"
InStr (startPos'n, strSearched, Character InStr(4,strString, "o") = 7
strToFind, Compare) position
3. InStrRev(strString, "up", Len(strString),1) = ____;
Len (strIength); since a Number of Len(strString) = 31
function, pos'n starts at 1 characters
InStrRev (strSearched,strToFind, Character InStrRev(strString, "up", 31,1) = 4
startPos'n, 0 or 1); 0- position
binary
comparison(default)
4. InStrRev(strString, "OS", Len(strString),0) = ____; InStrRev(strString, "OS", 31,1) = 0 since "OS" not in strString
5. InStrRev(strString, "OR", Len(strString),1) = ____; InStrRev(strString, "OR", 31,1) = 14 since case is ignored
6. InStrRev(strString, "OR", Len(strString),0) = ____; InStrRev(strString, "OR", 31,1) = 0 since case is NOT ignored

Dim str1 As String = "Please don't lose hope."


1. Mid(str1.Substring(7, 5), 2, 2) = ____; Mid("don't", 2, 2) = "on"
Substring (startPos'n, Length) string str1.Substring(7, 5) = "don't”
2. InStrev(str1.Replace(".", "hope"), "o") = ____; InStrev("Please don't lose hopehope", "o") = 24
Replace (oldValue, newValue) string str1.Replace(".", "hope") =
"Please don't lose hopehope"
3. str1.Remove(7, 6).Substring(7, 4) = ____;
str1 value is still "Please don't lose hope." even after code passes item2
Had the code been str1= str1.Replace(".", "hope"), then str1="Please don't lose hopehope"
For item3, apply the string class methods from left to right:
str1.Remove(7, 6) = "Please lose hope."
"Please lose hope.".Substring(7, 4) = “lose”
Remove (startPos'n,#CharToDel) string Removes characters from the middle of a string
4. str1.Insert(Len(str1),"la la”).EndsWith(".") = ____;
Again, apply the string class methods from left to right:
Len(str1)=23 recall: Len starts at position 1
str1.Insert(23,"la la”) = "Please don't lose hope.la la" recall: Insert starts at position 0
"Please don't lose hope.la la".EndsWith(".") = FALSE it ends with “a”

Dim str2 As String = "I’m drunk, I love you."


Dim str3 As String = "Baka bukas"
‘codes are executed in series
1. Mid(Microsoft.VisualBasic.Right(str2, 12), 2, 1) = ____
Microsoft.VisualBasic.Right(str2, 12) = “ I love you."
Mid(“ I love you.", 2, 1) = “I”
2. Mid(str2, InStr(1, str3, " "), 6) = ____
InStr(1, str3, " ") = 5
Mid(str2, 5, 6) = “drunk,”
3. Mid(str2, 1) = Mid(str3, 1)
Analyze first the statement on the right side of the equation
Mid(str3, 1) = "Baka bukas"
Mid(str2, 1) = "Baka bukas" => returns "Baka bukas I love you."
4. Mid(str2, 12, 10) = "Asan ba ko sayo?" => returns "Baka bukas Asan ba ko."

You might also like