Put something like
textBox1.Text = textBox1.Text.Replace("::", "0000:0000")
in the
Validating
event of the textbox.
Or if you want it to happen as the user types then put it in the
TextChanged
event - not my favourite.
[EDIT]
I'm guessing you could have several of these so I've tidied this up a bit as follows:
I created a dictionary of things you want to replace with things you want to replace them with, and populated it in a convenient place (in my case Form_Load)
Dim transpose As Dictionary(Of String, String) = New Dictionary(Of String, String)
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
transpose.Add("::", "0000:0000")
transpose.Add(";;", "another")
transpose.Add(";@", "andanother")
End Sub
I then created an extension method for strings to do all of the substitutions which I placed in Extensions.vb in my project
Imports System.Runtime.CompilerServices
Module Extensions
<Extension()> Public Function ReplaceAll(ByVal InputValue As String, transpose As Dictionary(Of String, String)) As String
Dim s As String = InputValue
For Each kvp As KeyValuePair(Of String, String) In transpose
s = s.Replace(kvp.Key, kvp.Value)
Next
Return s
End Function
End Module
I can then use that method in the validating event as above...
Private Sub TextBox1_Validating(sender As System.Object, e As System.ComponentModel.CancelEventArgs) Handles TextBox1.Validating
TextBox1.Text = TextBox1.Text.ReplaceAll(transpose)
End Sub
Note you will also need
Imports WindowsApplication2.Extensions
in Form1.vb