Is there a way to override Visual Basic Implicit Conversions

  • Thread starter Thread starter Alex Bilger
  • Start date Start date
Is there a way to override Visual Basic Implicit
Conversions ?

for example:
----
Dim s As String
Dim i As Integer
i=s
s=i
---

Option Strict On
is there a way for the system to call a customformatter or
any class that i code for the conversion string->integer
or integer->string without changing the VB Code

Look at the IFormatProvider interface. You can write a custom formater
and then just pass an instance to the convert class when doing the
conversion...

Dim myFormater As New CustomFormater
Dim i As Integer
Dim s As String = "10"

s = Convert.ToInt32(s, myFormater)

HTH
 
My vote is for option strict and explicit conversion as well. As Dan
Appleman so elegantly put it "Option strict Off is Option Slow on" Strict
typing is well worth the hassle.
 
Option Strict ON for president....

William Ryan said:
My vote is for option strict and explicit conversion as well. As Dan
Appleman so elegantly put it "Option strict Off is Option Slow on" Strict
typing is well worth the hassle.
 
Back
Top