Hint for the Loop assignment:
look into
=
<>
keywords: Not, While, Until
Not y = 5
y <> 5
Do
Loop While I = 6
same as
Do
Loop Until Not I = 6
Do
Loop Until I <> 6
_____
x = v 3
we started the section called Numbers
Constant as Opposed a Variable
constant value never changes
Const PI As Double = 3.14159
avoid Magic numbers
instead of * 4
we would write * ArraySize
scope:
Local variables
Global (class-level) variables
scope: where a variable has a definition
related to lifetime: how long a variable exists
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim x As Integer
x = 6
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' this is a syntax error
'Button1.Text = x
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
End Sub
End Class
Public Class Form1
' this is a class-level
' or non-local, or global
' variable
Dim x As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
x = 0
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' this is NOT a syntax error
x = x + 1
Button1.Text = x
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
End Sub
End Class
the With construct:
With lstResults.Items
.Clear()
.Add(Math.Sqrt(5 * b + 1))
.Add(Int(a ^ b + 0.8))
.Add(Math.Round(a / b, 3))
End With
Alternatively:
lstResults.Items.Clear()
lstResults.Items.Add(...)
lstResults.Items.Add(...)
lstResults.Items.Add(...)
Office Hour:
Wed 3-4 Adjunct Room, across from Cs Dept Office
joshwaxman@gmail
Trace through a program
Assignment 6
"Numbers"
questions 30 - 46
60-72
even numbers only
NOT even assigned yet
No comments:
Post a Comment