Is there a way to override Visual Basic Implicit Conversions

T

Tom Shelton

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
 
W

William Ryan

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.
 
A

Ale K.

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top