vandy
vandy

Reputation: 63

how do I implicitly convert enumtypes in Vb.Net

I am getting below error.

Error BC30512 Option Strict On disallows implicit conversions from 'clsDataTypes.enmMiscTransTypes' to 'clsDataTypes.enmMiscTransDistributions'".

Below mentioned is the code and I am passing an optional parameter to a sub like below.

Public Sub NotifyDisbursementDistribChanged(
    Optional ByVal enmRemovedDistribOption As clsDataTypes.enmMiscTransDistributions = clsDataTypes.enmMiscTransTypes.ValueNotSet)

End Sub

These two are the enumtypes.

Public Enum enmMiscTransDistributions
    ValueNotSet = -1
    Check = 0
    Wire = 1
    PlanWire = 3
    Test2= 9
End Enum

Public Enum enmMiscTransTypes
    ValueNotSet = -1
    MiscReceipt = 1         
    test2= 9        
    test5= 11

End Enum

Upvotes: 0

Views: 112

Answers (1)

djv
djv

Reputation: 15772

So why use the other enum type?

Public Sub NotifyDisbursementDistribChanged(
    Optional ByVal enmRemovedDistribOption As clsDataTypes.enmMiscTransDistributions = clsDataTypes.enmMiscTransDistributions.ValueNotSet)

End Sub

I mean, what is the point of using the wrong enum? They both have ValueNotSet = -1. So just use the correct one...?

Upvotes: 1

Related Questions