Tuesday, December 21, 2010

Chapter 17- Sub Procedures

Page 263-264 - Do the problem from the reading (weekly pay solution)
Page 367369 - Do problem from reading (Birthday Solution)

Pick 2 out of the 3... or do them all
Page 381-382- Problem 4- Grade Solution- then #5 Modify Grade Solution

Problem #7- Water Bill

Problem #8- Cable Company

Friday, December 17, 2010

Yahtzee Stuff

'Rolls 3 times and disables button
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btndiceRoll.Click
countRolls = countRolls + 1
Timer1.Enabled = True
If countRolls = 3 Then
btndiceRoll.Enabled = False
End If
End Sub

'Dice change 10 times and holding dice
If Hold1.Checked = False Then
r1 = Int(Rnd() * 6) + 1
End If
' rnd picks a number between 0 and .999999
If r1 = 1 Then
Dice1.Load("c:\Programming2010\Dice\d1.gif")
End If
If r1 = 2 Then
Dice1.Load("c:\Programming2010\Dice\d2.gif")
End If
If r1 = 3 Then
Dice1.Load("c:\Programming2010\Dice\d3.gif")
End If
If r1 = 4 Then
Dice1.Load("c:\Programming2010\Dice\d4.gif")
End If
If r1 = 5 Then
Dice1.Load("c:\Programming2010\Dice\d5.gif")
End If
If r1 = 6 Then
Dice1.Load("c:\Programming2010\Dice\d6.gif")
End If

'rolls Dice 10 times before stopping
If countTimes = 10 Then
Timer1.Enabled = False
countTimes = 0
End If

Tuesday, December 14, 2010

Using INPUT to create a STORY

Dim strName As String
Dim strColor As String
Dim intAge As Integer
Dim strHairColor As String
Dim x As Integer


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
x = x + 1
If x = 1 Then
strName = InputBox("What is your name")
strColor = InputBox("What is your favorite color")
intAge = InputBox("What is your Age")
strHairColor = InputBox("What is the color of you hair")
End If
If x = 2 Then
lblTitle.Text = "The Story of " & strName
End If
btnStart.Text = "Continue"
If x = 3 Then
lblTitle.Text = "There was a person named " & strName & ControlChars.NewLine & " who had only $" & intAge.ToString

End If

Monday, December 13, 2010

Keypress- only press keys from 1 to 9

Private Sub txtNumber_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtNumber.KeyPress

If (e.KeyChar < "1" Or e.KeyChar > "9") AndAlso e.KeyChar <> ControlChars.Back Then
e.Handled = True
End If

End Sub

Friday, December 10, 2010

Chapter 14- #5 Multiplication-
Do
intProduct = intNumber * intCounter
lblTable.Text = lblTable.Text & intNumber.ToString & " * " & intCounter.ToString & " = " & intProduct.ToString & ControlChars.NewLine
intCounter = intCounter + 1
Loop While intCounter <= 9

Monday, December 6, 2010

Chapter 15- Loops- For-Next Statements

'Chapter 15 Assignment- programs #5, 6,7,8 (Pick 3)

' The following is Kind-of from the reading
For intCountDown As Integer = 10 To 1 Step -1
lblCountToBlastOff.Text = intCountDown
Me.Refresh()
System.Threading.Thread.Sleep(200)
Next intCountDown
My.Computer.Audio.Play("H:\Programming2010\Spaceship Solution-Version 1\ZZ.wav")
lblCountToBlastOff.Text = "Blast Off!"
Me.Refresh()
System.Threading.Thread.Sleep(500)
' hide the label control
lblCountToBlastOff.Visible = False
' drag the spaceship to the top of the form
Do While picSpaceship.Top > 0
picSpaceship.Top = picSpaceship.Top - 10
Me.Refresh()
System.Threading.Thread.Sleep(200)
Loop

Thursday, December 2, 2010

Chapter 14- Do Loops

Page 310- Required: Do the sample program on page 302-303 Good Morning
(Note - You can substitute other end-of-the-Chapter- problems for these
Number 5- Name it Mutiplication Problem
Number 7- Open Figure this out
Number 8- Swat the Bugs

To combine two strings:
strFirstName ="Bob"
strLastName = "Gill"
intAge = 39
'strFirstName & " " & strLastName equals Bob Gill (with a space between the two words)
'strLastName & ", " & strFirstName equals Gill, Bob
lblStatement.text = "He is " & intAge.ToString & "!" lblState.text equals He is 39!