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

Posted on 2008-11-11
Last Modified: 2013-11-26
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.

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.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

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?)
    firstName = fullName.Substring(0, firstSpace)  ??  (THIS STATEMENT IS SAYING REMOVE THE FIRST
End If
Question by:nosurf2day
    LVL 53

    Expert Comment

    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

    If firstSpace = -1 Then
        firstName = fullName
        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:
    Name = "Edward C Koop" --> firstname = "Edward"
    Name = "Edward_C_Koop" --> firstname="Edward_C_Koop"
    LVL 53

    Expert Comment

    Clarification of 14
    Dim s1 As String = "abc"
    Dim s2 As String = s1
    s2 = "def"
    s1 = "abc"
    s2 = "def"
    LVL 53

    Expert Comment

    Dim companyName As String = "Mike Murach and Associates"
    Dim index1 As Integer = companyName.IndexOf(" ")  
    Dim index2 As Integer = companyName.IndexOf("Inc.")  

    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

    Author Comment

    Clarification of 14
    Dim s1 As String = "abc"
    Dim s2 As String = s1
    s2 = "def"
    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
    LVL 53

    Accepted Solution

    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

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Suggested Solutions

    IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
    Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    730 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now