Exam coming up, I have questions I need help answering.

I have an upcoming exam and I don't have access to my professor and I have questions that the book is not clarifying for me.  The book that the class is using is Murach's Visual Basic 2008.

iI will list the questions will by numbers.  I understand that there are alot of questions here but I really need a good grade on this exam and these are the areas that I am still unsure of.  Some of the questions, I have tried to answer and I posted a comment in (), it my guess is correct could you annotate so.  If not could you help me get on base.

I am taking the exam tomorrow at 11.  I have been buried in this book for a couple of days now and I need help.  I am using this site as a last resort.  I figured individuals on here are much more proficient than myself so I mine as well ask the experts.  

I want to thank anyone in advance that is willing to answer any of these questions for me.  God Bless and Happy Veterans Day.  I myself am an "Iraq Veteran" in 2003.

13.  Code that uses the IndexOf method  (THE PROFESSOR POSTED THE COMMENTS AT THE END OF EACH STATEMENT, I DONT UNDERSTAND WHAT HE IS REFERRING TO THOUGH)
Dim companyName As String = "Mike Murach and Associates"
Dim index1 As Integer = companyName.IndexOf(" ")     ' 4 (IS THIS NOTING WHERE THE FIRST SPACE IS
                                                                                              AND REFERERENCING IT'S POINT AS INDEX1?)
Dim index2 As Integer = companyName.IndexOf("Inc.")  ' -1 (THIS ISN'T IN THE COMPANY NAME AT THIS
                                                                                                 POINT SO I AM CONFUSED?)
Dim index3 As Integer = companyName.LastIndexOf(" ") ' 15 (THIS IS REFERENCING THE THIRD SPACE
                                                                                                   AFTER THE AND?)

Dim index4 As Integer = companyName.IndexOf(a)   ??  (THIS IS REFERENCING THE FIRST LETTER A?
                                                                                               WHAT ANNOTATES IF ITS NOT THE FIRST  
                                                                                               LETTER A, AND IS REFERING TO THE FIRST
                                                                                               WORD WITH FIRST LETTER A? )
Dim index5 As Integer = companyName.LastIndexOf(a) ?? (BASED ON THE FIRST REFERENCE I AM
                                                                                                  GUESSING THAT IT IS REFERRING TO THE
                                                                                                  LAST WORD WITH THE FIRST LETTER A IN
                                                                                                  THE STRING?)

Code that uses the Remove, Insert, and Replace methods
companyName = companyName.Remove(0, index1 + 1)  ?? (DOES THIS SAY REMOVE THE FIRST
                                                                                                 WORD, "MIKE"?)

companyName
   = companyName.Insert(companyName.Length, ", Inc.") ??   (DOES THIS SAY INSERT "Inc." AT THE
                                                                                                    END OF THE COMPANY NAME?)

companyName _
    = companyName.Replace("and", "And")
                            ' Murach And Associates, Inc.                       (THIS CODE IS JUST SAYING REPLACE
                                                                                                    ONE DESIGNATED WORD FOR
                                                                                                   ANOTHER?)

companyName = companyName.Insert(companyName.IndexOf(and),  JJ)   ??  (THIS CODE IS SAYING
                                                                                                                                    INSERT "JJ" IN THE
                                                                                                                                   PLACE OF "and"?)



14.  Code that copies one string to another string
Dim s1 As String = "abc"
Dim s2 As String = s1
         ' This creates a new string with the value "abc"
s2 = "def"
         ' This doesn't change the value stored in s1
          s1 ??  

Answer: (abc?)

15.  Application Examples: (1) Code that parses a first name from a name string

Dim fullName As String = " Edward C Koop   "       

fullName = fullName.Trim   'fullname ??      

Answer:     ( "Edward C Koop"?)

Dim firstSpace As Integer = fullName.IndexOf(" ")   ' 6          (FIRST SPACE?)
Dim firstName As String = ""   

If firstSpace = -1 Then
    firstName = fullName        ??  (THIS STATEMENT COMPLETELY CONFUSES ME?)
Else
    firstName = fullName.Substring(0, firstSpace)  ??  (THIS STATEMENT IS SAYING REMOVE THE FIRST
                                                                                      SPACE?)
End If
nosurf2dayAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

DhaestCommented:
Litlte clarrification of 14:
a) Dim fullName As String = " Edward C Koop   "       
    fullName = fullName.Trim
    FullName will be: "Edward C Koop"
The trim-function removes the trailing and leading spaces in a string

b)
If firstSpace = -1 Then
    firstName = fullName
Else
    firstName = fullName.Substring(0, firstSpace)  
End If
--> If there is a space in the fullname, the firstname will only be filled with the text before the space. If there is no space in the name, it will be filled with the complete name:
Example:
Name = "Edward C Koop" --> firstname = "Edward"
Name = "Edward_C_Koop" --> firstname="Edward_C_Koop"
0
DhaestCommented:
Clarification of 14
Dim s1 As String = "abc"
Dim s2 As String = s1
s2 = "def"
Solution:
s1 = "abc"
s2 = "def"
0
DhaestCommented:
Dim companyName As String = "Mike Murach and Associates"
Dim index1 As Integer = companyName.IndexOf(" ")  
Dim index2 As Integer = companyName.IndexOf("Inc.")  

Solution
index1 = 4   --> if we take a look at the string of the companyname, we'll notice that on the fourt position, there is a space
index2 = -1 --> in the companyname, we don't find a substring ("inc."). If it's not there, the indexOf-function will return -1

For more information about
indexOf: http://msdn.microsoft.com/en-us/library/system.string.indexof.aspx
insert: http://msdn.microsoft.com/en-us/library/system.string.insert.aspx
0
nosurf2dayAuthor Commented:
Clarification of 14
Dim s1 As String = "abc"
Dim s2 As String = s1
s2 = "def"
Solution:
s1 = "abc"
s2 = "def"

What does this statement mean then? Dim s2 As String = s1

To me it is saying that s2 is now equal to s1 which is abc,  but then it defines s2 as being def so does that change what the other statement is saying
0
DhaestCommented:
Dim s2 As String = s1
you can also see it as:
Dim s2 as string
s2 = s1
--> create a new string and assign the value of the string s1 (in this case "abc") to the new created string
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.