In this post you learn about vb.net text box border color change it is very easy task just take some text boxes from tool box then use the below coding as per video instruction.

Public Class Form1 Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint Dim g As Graphics = e.Graphics Dim pen As New Pen(Color.Blue, 4.0) For Each ctr As Control In Me.Controls If TypeOf ctr Is TextBox Then g.DrawRectangle(pen, New _ Rectangle(ctr.Location, ctr.Size)) End If Next pen.Dispose() End Sub End Class

This coding is use for when you fill some data in text box then border color will be change

Public Class Form1 Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint With TextBox1 Dim p As New Pen(If(TextBox1.Text <> "", Color.Green, Color.Red), 3) e.Graphics.DrawRectangle(p, .Left - 1, .Top - 1, .Width + 2, .Height + 2) p.Dispose() End With End Sub Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged Me.Invalidate() End Sub End Class
 
Top