ed209
ed209

Reputation: 838

Vb enum not returning correct value

I'm trying to use an enum and am going mad trying to get the right value out of it.

Enum DiscountRates As Long
    x = 0.05
    y = 0.1
    z = 0.15
End Enum

So if I do

MessageBox.Show(DiscountRates.x) 

I'd think I would get back .05 or i'd be able to use it to assign a value.... If I print it out it will only ever print 0

I originally had it as a double, but VB won't let it be declared as one

Upvotes: 0

Views: 175

Answers (1)

Ofer Zelig
Ofer Zelig

Reputation: 17470

Enums only support integers. You need to resort to other options, as:

   Const x As Single = 0.05

Have a look: https://stackoverflow.com/a/655055/290343

Upvotes: 3

Related Questions