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
Tuesday, December 21, 2010
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
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
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
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
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
' 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!
(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!
Wednesday, November 24, 2010
Reading Data from a Notepad file
Reading Data from a text file and then placing it in a Listbox
Dim x As Integer
Dim r As Integer
Dim guess As String
Dim animal(5) As String
Dim inFile As IO.StreamReader
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
inFile = IO.File.OpenText("h:\programming2010\animals.txt")
Do Until inFile.Peek = -1
x = x + 1
animal(x) = inFile.ReadLine
listData.Items.Add(animal(x))
Loop
inFile.Close()
Dim x As Integer
Dim r As Integer
Dim guess As String
Dim animal(5) As String
Dim inFile As IO.StreamReader
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
inFile = IO.File.OpenText("h:\programming2010\animals.txt")
Do Until inFile.Peek = -1
x = x + 1
animal(x) = inFile.ReadLine
listData.Items.Add(animal(x))
Loop
inFile.Close()
Tuesday, November 23, 2010
Chapter 13 Assignments
This is the code for an input statement:
strInputSales = inputbox(strPrompt, strTITLE, "0.0")
Car Solution 1 on page 274
Car Solution 2 on page 278
Sales Express Solution on Page 280-86
Exercise on Page 292 (Pick 3 of the following)
#4- Average Sales Solution
#5- Weekly Pay Solution
#6- Raise Solution
#7- Sum Even Solution
strInputSales = inputbox(strPrompt, strTITLE, "0.0")
Car Solution 1 on page 274
Car Solution 2 on page 278
Sales Express Solution on Page 280-86
Exercise on Page 292 (Pick 3 of the following)
#4- Average Sales Solution
#5- Weekly Pay Solution
#6- Raise Solution
#7- Sum Even Solution
Do While and Do Until Loops
'A loop goes around and around until the condition is met
'Example of a Do While Loop- NOTE: intNum must be dimensioned
intNum =1 'If you don't set intNum to 1 then intNum = 0
Do While IntNum <=3
MessageBox.Show (intNum.ToString)
intNum= intNum +1
Loop
-------------------------------------------------------------------
'Example of a Do Until Loop:
intNum = 1
Do Until IntNum > 3
MessageBox.Show (intNum.ToString)
intNum= intNum +1
Loop
In the comment section, tell the output of each program for 5 points
'Example of a Do While Loop- NOTE: intNum must be dimensioned
intNum =1 'If you don't set intNum to 1 then intNum = 0
Do While IntNum <=3
MessageBox.Show (intNum.ToString)
intNum= intNum +1
Loop
-------------------------------------------------------------------
'Example of a Do Until Loop:
intNum = 1
Do Until IntNum > 3
MessageBox.Show (intNum.ToString)
intNum= intNum +1
Loop
In the comment section, tell the output of each program for 5 points
Monday, November 22, 2010
Converting data from a textbox to lower or upper case
Dim strCowBiscuit as String
'Let's say the textbox is txtCowBiscuit
strCowBiscuit = txtCowBiscuit.text.ToUpper
or
strCowBiscuit = txtCowBiscuit.Text.ToLower
This assignes a string variable (strCowBiscuit) to what's inside the textbox (txtCowBiscuit) and changes it to upper or lower case
'Let's say the textbox is txtCowBiscuit
strCowBiscuit = txtCowBiscuit.text.ToUpper
or
strCowBiscuit = txtCowBiscuit.Text.ToLower
This assignes a string variable (strCowBiscuit) to what's inside the textbox (txtCowBiscuit) and changes it to upper or lower case
Chapter 12 Exercises
Chapter 12- (use the methods learned from Shady Hollow)
Page 262- Exercise 3
for a point of extra credit, change the MaxLength of the Texbox to 1
Exercise 4- Open Department Solution
Change the textbox MaxLength to 1
Change the case to Upper
Make it so the textbox on accepts A, a, B, b
If user clicks the display button without entering a code,
display the text "not available"
Exercise 7- Open ABC Solutions
Modify the code so that it only accepts only numbers and backspace key
Page 262- Exercise 3
for a point of extra credit, change the MaxLength of the Texbox to 1
Exercise 4- Open Department Solution
Change the textbox MaxLength to 1
Change the case to Upper
Make it so the textbox on accepts A, a, B, b
If user clicks the display button without entering a code,
display the text "not available"
Exercise 7- Open ABC Solutions
Modify the code so that it only accepts only numbers and backspace key
Thursday, November 18, 2010
Programming code for using on the s, d, S, D or backspace
NOTE: to see if you do this right and you are successful, you should be able to put anything in the textbox except s, S, d, D or the backspace key
'First of all you need to go to the code and choose the name of the text box. The name should be something like: txtType and choose KEYPRESS
It will generate this code:
Private Sub txtType_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtType.KeyPress
'This is the code you put in the Keypress sub
' allows the text box to accept only the letters
' S, s, D, and d and the Backspace key for editing.
If e.KeyChar <> "S" AndAlso e.KeyChar <> "s" AndAlso e.KeyChar <> "D" AndAlso e.KeyChar <> "d" AndAlso e.KeyChar <> ControlChars.Back Then
e.Handled = True
End If
'First of all you need to go to the code and choose the name of the text box. The name should be something like: txtType and choose KEYPRESS
It will generate this code:
Private Sub txtType_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtType.KeyPress
'This is the code you put in the Keypress sub
' allows the text box to accept only the letters
' S, s, D, and d and the Backspace key for editing.
If e.KeyChar <> "S" AndAlso e.KeyChar <> "s" AndAlso e.KeyChar <> "D" AndAlso e.KeyChar <> "d" AndAlso e.KeyChar <> ControlChars.Back Then
e.Handled = True
End If
Subscribe to:
Posts (Atom)