Monday, February 14, 2011

Manipulationg Buttons and Textboxes

This code will manipulate a textbox on a form

 Public Class Form1
  
   Private Sub btnBackGroundColor_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBackgroundColor.Click
  
     'This changes the text colors back and forth between tomato and white
  
     If txtOutputbox.BackColor = Color.White Then
  
       txtOutputbox.BackColor = Color.Tomato
  
     Else
  
       txtOutputbox.BackColor = Color.White
  
     End If
  
   End Sub
  
   Private Sub button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
  
     'Enables the textbox
  
     If txtOutputbox.Enabled = False Then
  
       txtOutputbox.Enabled = True
  
     Else
  
       txtOutputbox.Enabled = False
  
     End If
  
   End Sub
  
   Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
  
     'This one it the same as the two above.
  
     If txtOutputbox.BorderStyle = BorderStyle.Fixed3D Then
  
       txtOutputbox.BorderStyle = BorderStyle.None
  
     Else
  
       txtOutputbox.BorderStyle = BorderStyle.Fixed3D
  
     End If
  
   End Sub
  
   Private Sub btnText_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnText.Click
  
     If txtOutputbox.Text = "If heaven was a mile away" Then
  
       txtOutputbox.Text = " "
  
     Else
  
       txtOutputbox.Text = "If heaven was a mile away"
  
     End If
  
   End Sub
  
 End Class
  

No comments:

Post a Comment