Click here to Skip to main content
15,887,083 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Ok, so, i created custom control volume for some media player, for silent sound is -10000 and for full sound is 0, i searched all over google and i din't found anything, so, how do i decrease -10000 to 0 when i increase value to 100.

What I have tried:

I created two properties:
VB
Public Property SetVolume() As Integer
        Get
            Return _SetVolume
        End Get
        Set(val As Integer)
            _SetVolume = val
            Refresh()
        End Set
    End Property

        Public Property Volume() As Integer
        Get
            Return _VolumeBar.Volume
        End Get
        Set(Val As Integer)
            _VolumeBar.Volume = Val
            Invalidate()
        End Set
    End Property

i tried to decrease SetVolume when i increase Volume.
VB
MediaPlayerVolume1.SetVolume = MediaPlayerVolume1.Volume
TxtVolume.Text = Trim(-10000 * MediaPlayerVolume1.SetVolume / 100)

I use "TxtVolume.Text" just for testing, to check if is working or not.
Posted
Updated 26-Apr-18 6:31am
Comments
Richard MacCutchan 26-Apr-18 11:51am    
-10000 + 100 = -9900.

Your question is not clear.
Florin Pănescu 26-Apr-18 12:01pm    
I can't be more clear then that.
I created custom control, like progressbar, i use that control for increase volume, the problem is, for silent is -10000 and for full is 0, i set progressbar maximum to 100, when i increase value to 100, i want other value to decrease until 0.
Richard MacCutchan 26-Apr-18 12:15pm    
If the maximum is 100 then 1 is (10000 / 100) which is 100. So for every 1 step on the progress bar you increase the volume value by 100. So increase to 1 will be -10000 + 100 = -9900, and increase to 100 will be -10000 + (100 * 100) = -10000 + 10000 = 0.

Get your 0 to 100 reading, multiply it by -100.
0   ->      0
1   ->   -100
...
100 -> -10000
If you need it reversed, then get your 0 to 100 reading, multiply it by 100 and subtract it from 10000:
0   -> -10000
1   ->  -9900
...
100 ->      0
 
Share this answer
 
Oh there ya go, thank you guys for that math solutions, @Richard MacCutchan i tried your solution, what i do is set progressbar Maximum to 10000, it looks like this:
VB
MediaPlayerVolume1.SetVolume = MediaPlayerVolume1.Volume
TxtVolume.Text = Trim(-10000 + (100 * 100) - 10000 + MediaPlayerVolume1.SetVolume)

With your math is working, i want your brain dude :)
Thank you guys so much for helping me.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900