A few small vb questions

Posted on 2006-11-14
Last Modified: 2010-04-23
1. What does the following statement do?  I am doing some review and cannot figure a few of these out.

outputLabel.Text = someListBox.Items(someListBox.SelectedIndex))

2. what is th value of I?

Dim n As Integer = 0
Dim i As Integer
Dim j As Integer

For i = 0 To 5
      For j = 0 To 5
           n += 1
      Next j
Next i

3. what is the value of I?

Dim i As Integer
For i = 0 To 10
        If i = 5 Then
             Exit For
        End If
Next i

4. What is wrong with the following loop?

Dim i as Integer
For i = 20 To 0
 '(some code)
Next i

5.  Which of the following loops will execute at least once and will end when the condition becomes True?

  Do While condition / Loop  
  Do Until condition / Loop  
  Do / Loop While condition  
   Do / Loop Until condition  

Question by:03xc600
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 16

Expert Comment

ID: 17943011
Hi 03xc600,

Is this homework?
LVL 70

Accepted Solution

Éric Moreau earned 325 total points
ID: 17943119
Hi 03xc600,

1. copy the text of the selected item of the list in a textbox
2. 6
3. 5
4. step -1 is missing
5. Do / Loop Until condition  


Assisted Solution

by:Jayadev Nair
Jayadev Nair earned 175 total points
ID: 17944554

2. 36 right?
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now


Expert Comment

by:Jayadev Nair
ID: 17944561

outputLabel.Text = someListBox.Items(someListBox.SelectedIndex))

This may throw exception if listbox donot hav string object. So try to assign displaytext or someListBox.Items(someListBox.SelectedIndex).toString()
LVL 70

Expert Comment

by:Éric Moreau
ID: 17945823
>>2. 36 right?

it can't be, the value of I range from 0 to 5 so its value after the loop is 6 (1 more then the greater value).

Expert Comment

by:Jayadev Nair
ID: 17948048
oh! sorry - I. I went after n

Author Comment

ID: 17951495
thanks guys, i think that the second one was 36, but i am not sure
LVL 70

Expert Comment

by:Éric Moreau
ID: 17952017
>>i think that the second one was 36, but i am not sure

it can't be, the value of I range from 0 to 5 so its value after the loop is 6 (1 more then the greater value). Drop the code into a test form and test it.

Featured Post

Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

Question has a verified solution.

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

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

615 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