标签云

微信群

扫码加入我们

WeChat QR Code

I want to use a track-bar to change a form's opacity.

This is my code:

decimal trans = trackBar1.Value / 5000;
this.Opacity = trans;

When I build the application, it gives the following error:

Cannot implicitly convert type 'decimal' to 'double'.

I tried using trans and double but then the control doesn't work. This code worked fine in a past VB.NET project.


Also, Decimal can't represent as wide a value as a Double. Decimal can only go up to +/-7.9228162514264337593543950335E+28; whereas a Double can go up to +/-1.79769313486232E+308

2018年07月19日36分05秒

I can't believe nobody got ever curious about this, but this seems to be the oldest question on Stack Overflow. It was originally asked Jul 31 '08 (Stack Overflow officially launched Sep 15, '08!).

2018年07月19日36分05秒

Wouldn't this just move the problem around? Rather than a problem with 5000, OP would have a problem with 100?

2018年07月19日36分05秒