VB NOTES PART 6 - • Be careful about off-by-one...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
2/10 Q: What is the smallest number of bits I need to store 50 colors? 6 bits (2^6=64) Dim bits As Integer = 0 Dim colors As Integer=1 Dim maxColors As Integer ‘read maxColors from user Do while colors<maxColors Bits + =1 Colors = colors^2 Loop Condition? True Statement 1 False Do while….loop Can also put condition at bottom Dim counter As Integer = 0 Do ‘ sth Counter +=1 Loop while counter <3 Statement 1 Condition? false True Dim ctr As Integer =1 Do while ctr >0 do while ctr<4 (repeat 3 times) ‘ something Ctr +=1 Loop Infinite loop (nonstop) Notes Make sure value of condition eventually changes
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: • Be careful about off-by-one errors-check boundary conditions • Initialize all variables • Counter-controlled iteration is very common- has its own control structure----New Windows Form: ListBox: a list of items, controlled by code (like a label, users can’t change it) entriesListBox.Items.Clear () ------------clear all the entries object object method entriesListBox.Items.Add (“New item”) entriesListBox.Items.Cont Mystring=entriesListBox. Item. Item (0) entriesListBox.Items.RemoveAt (2)...
View Full Document

This note was uploaded on 12/01/2011 for the course 6K 226 taught by Professor Staff during the Fall '10 term at University of Iowa.

Page1 / 2

VB NOTES PART 6 - • Be careful about off-by-one...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online