Monday, February 14, 2011

Assignment Three - Question Three

When button is clicked, it will create 3 labels and 3 textboxes associated with those labels. When textboxes are hovered over, change their background color. When it is not being hovered over, change the bacground color back to white.

 Public Class Form1
  
   Dim WithEvents txtone, txttwo, txtthree As New TextBox
  
   Dim WithEvents lblone, lbltwo, lblthree As New Label
  
   Private Sub btnMultiply_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMultiply.Click
  
     txtone.Height = 75
  
     txtone.Width = 100
  
     txtone.Text = "I Am Textbox One"
  
     txtone.Location = New Point(4, 1)
  
     txtone.BackColor = Color.White
  
     txttwo.Height = 75
  
     txttwo.Width = 100
  
     txttwo.Text = "I Am Textbox Two"
  
     txttwo.Location = New Point(225, 1)
  
     txttwo.BackColor = Color.White
  
     txtthree.Height = 75
  
     txtthree.Width = 100
  
     txtthree.Text = "I Am Textbox Three"
  
     txtthree.Location = New Point(450, 1)
  
     txtthree.BackColor = Color.White
  
     lblone.Height = 100
  
     lblone.Width = 100
  
     lblone.Text = "I Am Label One"
  
     lblone.Location = New Point(4, 85)
  
     lbltwo.Height = 100
  
     lbltwo.Width = 100
  
     lbltwo.Text = "I Am Label Two"
  
     lbltwo.Location = New Point(225, 85)
  
     lblthree.Height = 100
  
     lblthree.Width = 100
  
     lblthree.Text = "I Am Label Three"
  
     lblthree.Location = New Point(450, 85)
  
     Me.Controls.Add(txtone)
  
     Me.Controls.Add(txttwo)
  
     Me.Controls.Add(txtthree)
  
     Me.Controls.Add(lblone)
  
     Me.Controls.Add(lbltwo)
  
     Me.Controls.Add(lblthree)
  
   End Sub
  
   Private Sub txtone_mouseenter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtone.MouseEnter
  
     txtone.BackColor = Color.Red
  
   End Sub
  
   Private Sub txtone_mouseleave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtone.MouseLeave
  
     txtone.BackColor = Color.White
  
   End Sub
  
   Private Sub txttwo_mouseenter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txttwo.MouseEnter
  
     txttwo.BackColor = Color.Red
  
   End Sub
  
   Private Sub txttwo_mouseleave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txttwo.MouseLeave
  
     txttwo.BackColor = Color.White
  
   End Sub
  
   Private Sub txtthree_mouseenter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtthree.MouseEnter
  
     txtthree.BackColor = Color.Red
  
   End Sub
  
   Private Sub txtthree_mouseleave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtthree.MouseLeave
  
     txtthree.BackColor = Color.White
  
   End Sub
  
 End Class  

No comments:

Post a Comment