-
Mar 16th, 2018, 04:16 PM
#1
Thread Starter
Addicted Member
[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.
-
Mar 16th, 2018, 05:08 PM
#2
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
-
Mar 16th, 2018, 08:08 PM
#3
Re: Written code
Originally Posted by EmilyM1105
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.
-
Mar 16th, 2018, 08:17 PM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|