Text manipulations where classes are used to represent string and sentences.
For Example:
This program overloads the binary plus operator to add two complex numbers of type:
x = a + jb
Module Module1
Class Complex
Private x As [Double]
Private y As [Double]
Public Sub New()
End Sub
Public Sub New(ByVal real As [Double], ByVal image As [Double])
x = real
y = image
End Sub
Public Shared Operator +(ByVal c1 As complex, ByVal c2 As complex) As complex
Dim c3 As New Complex()
c3.x = c1.x + c2.x
c3.y = c1.y + c2.y
Return (c3)
End Operator
Public Sub Display()
Console.Write(x)
Console.Write("+j" & Convert.ToString(y))
Console.WriteLine()
End Sub
End Class
Sub Main()
Dim a As Complex, b As Complex, c As Complex
a = New Complex(2.5, 3.5)
b = New Complex(1.6, 2.7)
c = a + b
Console.Write("a=")
a.Display()
Console.Write("b=")
b.Display()
Console.Write("c=")
c.Display()
End Sub
End Module