Visual Basic.NET Windows Forms Hello World Homework Assignment.

19
Visual Basic.NET Windows Forms Hello World Homework Assignment

Transcript of Visual Basic.NET Windows Forms Hello World Homework Assignment.

Page 1: Visual Basic.NET Windows Forms Hello World Homework Assignment.

Visual Basic.NETWindows Forms

Hello World Homework Assignment

Page 2: Visual Basic.NET Windows Forms Hello World Homework Assignment.

Homework Assignment

• This assignment builds on the Windows Forms Hello World class exercise.

Page 3: Visual Basic.NET Windows Forms Hello World Homework Assignment.

Now Lets Add Some More Controls to Our Project (see next slide)

• Add a TextBox– Set the Font Size Property to– Clear the Text Property

• Add two Buttons to the Side– Set the Top Button Text Property to "Say Hi"– Set the Bottom Button Text Property to "Clear"

• Add Three Buttons at the Bottom– Clear the Text Property for each bottom button– Set the BackColor Properties to Red, Blue, Green

Page 4: Visual Basic.NET Windows Forms Hello World Homework Assignment.
Page 5: Visual Basic.NET Windows Forms Hello World Homework Assignment.

Now Let's Write Some Code

• We are going to change the label display using whatever name is typed into the text box. If no name is typed we will display a message asking that a name be entered.

• When the clear button is click we will reset the label text to "Hello World" and clear the TextBox.

• When one of the three color buttons is clicked we will change the backgroud and foreground colors on the form. Feel free to exercise your creative freedom and choose whatever colors you like.

Page 6: Visual Basic.NET Windows Forms Hello World Homework Assignment.

First the "Say Hi" Button

• Double Click on the "Say Hi" button and add the following code.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

If TextBox1.Text = "" Then

MessageBox.Show("Please enter a name.")

Else

Label1.Text = "Hi " + TextBox1.Text

End If

End Sub

Page 7: Visual Basic.NET Windows Forms Hello World Homework Assignment.

Next the Clear Button

• Double Click on the "Say Hi" button and add the following code.

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click

TextBox1.Text = ""

Label1.Text = "Hello World"

Me.BackColor = Color.Gray

Me.ForeColor = Color.White

Label1.BackColor = Me.BackColor

Label1.ForeColor = Me.ForeColor

End Sub

Page 8: Visual Basic.NET Windows Forms Hello World Homework Assignment.

For Each Color Button Enter the following code with your choice of color.

Note: Chose your colors to match the button color.

Private Sub Button4_Click(ByVal sender As System.Object,

ByVal e As System.EventArgs) Handles Button4.Click

Me.BackColor = Color.Green

Me.ForeColor = Color.Yellow

Label1.BackColor = Me.BackColor

Label1.ForeColor = Me.ForeColor

End Sub

Note: In Me.BackColor Me is the form. The code is the same as Form1.BackColor = Color.Green

Page 9: Visual Basic.NET Windows Forms Hello World Homework Assignment.
Page 10: Visual Basic.NET Windows Forms Hello World Homework Assignment.

Now Build and Run the Application

Page 11: Visual Basic.NET Windows Forms Hello World Homework Assignment.

The Running Application Should Look Like This

Page 12: Visual Basic.NET Windows Forms Hello World Homework Assignment.

or This...

Page 13: Visual Basic.NET Windows Forms Hello World Homework Assignment.

or This...

Page 14: Visual Basic.NET Windows Forms Hello World Homework Assignment.
Page 15: Visual Basic.NET Windows Forms Hello World Homework Assignment.

Homework Assignment

Page 16: Visual Basic.NET Windows Forms Hello World Homework Assignment.

Homework Assignment

• Part I - Please email me the following, this week if possible– Your full name, nick name, Student ID #– Your home phone and work Phone– Any additional email addresses you'd like me to use– Your background in computing/programming– Any experience with .NET, other courses?– Your objective or goals for this course– Any topics you have a special interest in covering?– Any other issues or questions you may have?

Page 17: Visual Basic.NET Windows Forms Hello World Homework Assignment.

Homework Assignment

• Part II – Due Next Wednesday– Expand on this last Windows Form exercise– Have some fun with it– Try additional text boxes, controls, buttons, whatever...– When you are satisfied, zip the project file and email it

to me

Page 18: Visual Basic.NET Windows Forms Hello World Homework Assignment.

Tenitive Grade Matrix for this AssignmentThis project will be graded as follows:

Form Layout:

1. Form Layout and Title (5 points)

2. LabelBox (5 points)

3. TextBox (5 points)

4. "Say Hi" and "Clear" Buttons (10 points, 5 points each)

5. Three Color Buttons (15 points, 5 points each)

Button Functions (does it work as designed?):

1. "Say Hi" Button (5 points)

2. Use of MessageBox (5 points)

3. "Clear" Button (5 points)

4. Three Color Buttons (15 points, 5 points each)

Absense of Execution Errors (5 points)

Creativity (25 points)

Note: Partial credit maybe awarded where appropriate.

Page 19: Visual Basic.NET Windows Forms Hello World Homework Assignment.