Solved

A few small vb questions

Posted on 2006-11-14
8
151 Views
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  





0
Comment
Question by:03xc600
8 Comments
 
LVL 16

Expert Comment

by:Hillwaaa
Comment Utility
Hi 03xc600,

Is this homework?
0
 
LVL 69

Accepted Solution

by:
Éric Moreau earned 325 total points
Comment Utility
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  

Cheers!
0
 
LVL 6

Assisted Solution

by:Jayadev Nair
Jayadev Nair earned 175 total points
Comment Utility
emoreau,

2. 36 right?
0
 
LVL 6

Expert Comment

by:Jayadev Nair
Comment Utility

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()
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 69

Expert Comment

by:Éric Moreau
Comment Utility
>>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).
0
 
LVL 6

Expert Comment

by:Jayadev Nair
Comment Utility
oh! sorry - I. I went after n
0
 

Author Comment

by:03xc600
Comment Utility
thanks guys, i think that the second one was 36, but i am not sure
0
 
LVL 69

Expert Comment

by:Éric Moreau
Comment Utility
>>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.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

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 …
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

762 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now