Results 1 to 4 of 4

Thread: [RESOLVED] Written code

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2018
    Posts
    136

    Resolved [RESOLVED] Written code

    I'm taking a written test right now, so Im having to write out all the codes on paper. Not sure why it's so much easier for me to type it than write it!!?? I'm still learning..so please correct me if I'm wrong. Thanks in advance!!

    So I was told to consider the following snippet and write out the answers to these questions..My answers are in RED

    Code:
    Dim intx as Integer = 0
    Do
    intx += 1
    Loop until intx = 0
    1. What is code an example of? How would you change this code to make the loop end after 10 iterations?

    It's an example of Iterative Statement, a Do..Loop (until)

    Code:
    Dim intx as Integer = 0
    Do
    intx += 1
    Loop until intx = 10
    2.Write the code to populate and declare an array of five items.

    3. Create a two-button message box named Decision Time. Your message box should tell the user "It is time to make a choice." Provide buttons for OK and/or Cancel.

    Code:
    MessageBox.Show ("It is time to make a choice", "Decision Time",
    MessageBoxButtons.OKCancel)
    I'm working on number 2 now.
    Last edited by EmilyM1105; Mar 16th, 2018 at 05:32 PM.

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,988

    Re: Written code

    If it's a test, then we probably shouldn't be helping you with any of it. Still, you have an error in #1, and I question whether or not a statement like "It is time to make a choice." is really a question. Of course, that's a problem with the test, not the answer.
    My usual boring signature: Nothing

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: Written code

    Quote Originally Posted by EmilyM1105 View Post
    Not sure why it's so much easier for me to type it than write it
    So type it then. Write your code in VS and then simply copy it to the test sheet when it's done.

  4. #4
    PowerPoster i00's Avatar
    Join Date
    Mar 2002
    Location
    1/2 way accross the galaxy.. and then some
    Posts
    2,388

    Re: Written code

    I imagine the written test has passed ... since he is posting here.. prob got marks and wants to know why:

    1. Depends is overflow checking on or off? - if off then a very long loop that will eventually overflow, if not an loop that is quite large ... change Loop until intx = 10
    2. Dim arr = {1,2,3,4,5}
    3. .. doing this from memory - since u were doing without looking so will I .. so may be wrong... If MsgBox("Hello",,vbMsgBox.OkCancel) = vbMsgBoxResult.OK Then ....

    Kris

    EDIT:

    ... yep was wrong:
    If MsgBox("Hello", MsgBoxStyle.OkCancel) = MsgBoxResult.Ok Then
    ... haven't used a message box in years tho per-say ... as I wrote a wrapper class that can effectively extend it with custom buttons etc.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width