Solved

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

Posted on 2008-11-11
Medium Priority
210 Views
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.

10.  A Sub procedure that converts an array of inches to an array of centimeters
Private Sub ConvertToEven( _
ByRef measurements() As Double)
For i As Integer = 0 To measurements.Length - 1
measurements(i) *= 2
Next
End Sub

' Statements that declare an array and call the procedure
Dim measurements() As Double = {1, 2, 3}
Me.ConvertToEven(measurements)

What are the values of measurements()???

-  Again, I have no idea how to work this?

10.  Code that uses an index to access a character in a string
Dim chars As String = "abcdefg"
Dim a As Char = chars(0)               ' a = "a"
Dim b As Char = chars(1)               ' b = "b"
Dim c As Char = chars (4)               c = ??? (2)  Is this correct, 4 would be "e"?
String must be an array??? Yes or NO, why?
-  I don't understand the question.

11. Code that uses a For Each loop to access each character in the string
Dim chars As String = "abcdefg"

Dim charsAndSpaces As String = ""
For Each c As Char in chars                      (WHAT DOES THE "c" MEAN IN THIS STATEMENT?)
charsAndSpaces &= c & " "
Next
MessageBox.Show(charsAndSpaces, "String Test")

12. Insert(startindex, string)
Returns a string with the specified string inserted beginning at the specified position.

-  There isn't an example of this, can someone code an example?
0
Question by:nosurf2day
• 2

LVL 53

Expert Comment

ID: 22938151
10. Sub-procedure. In this procedure, we'll loop the array. For each value in the array, we will multiply it with 2 (*= 2). The result will look like this
measurements(0) = 2
measurements(1) = 4
measurements(2) = 6

10.  Code that uses an index to access a character in a string
Dim chars As String = "abcdefg"
Dim a As Char = chars(0)               ' a = "a"
Dim b As Char = chars(1)               ' b = "b"
Dim c As Char = chars (4)   --> this will contain e
--> the character at the 5th position of the string (because an array starts from 0)
chars(0) --> a
chars(1) --> b
chars(2) --> c
chars(3) --> d
chars(4) --> e
chars(5) --> f
chars(6) --> g

11. Code that uses an index to access a character in a string
Output will be: "a b c d e f g "
charsAndSpaces &= c & " " --> each time when we have a char (a, b, ...), we will add it together with a space to the string
When we break the loop in pieces we will see the string growing like this:
""
"a "
"a b "
"a b c "
...
0

Author Comment

ID: 22940725
so what i am understanding in 11 is that the code is just saying create a string with abcdefg and put a space in between each character?  That's it?  Dang that was too easy.

I am still unsure of 12 though.  Any help?  You have rocked every section so far.  You would ace this test!  Heck, you probably could teach the class.
0

LVL 53

Accepted Solution

Dhaest earned 2000 total points
ID: 22940853
>> so what i am understanding in 11 is that the code is just saying create a string with abcdefg and put a space in between each character?  That's it?  Dang that was too easy.
Correct

>> 12. Insert(startindex, string)
Returns a string with the specified string inserted beginning at the specified position.
Examples: see http://msdn.microsoft.com/en-us/library/system.string.insert.aspx
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Loops Section Overview
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
###### Suggested Courses
Course of the Month14 days, 22 hours left to enroll