Link to home
Start Free TrialLog in
Avatar of 03xc600
03xc600

asked on

A few small vb questions

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  





Avatar of Hillwaaa
Hillwaaa
Flag of Australia image

Hi 03xc600,

Is this homework?
ASKER CERTIFIED SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial

1.
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()
>>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).
oh! sorry - I. I went after n
Avatar of 03xc600
03xc600

ASKER

thanks guys, i think that the second one was 36, but i am not sure
>>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.