好吧,所以,我为某些媒体播放器创建了自定义控制音量,因为静音是-10000,而完整声音是0,我搜遍谷歌并且我找不到任何东西,所以,我如何减少 - 当我将值增加到100时,10000到0. 我尝试过: 我创建了两个属性:
公共 属性 SetVolume() As 整数 获取 返回 _SetVolume 结束 获取 设置(val As 整数) _SetVolume = val 刷新() 结束 设置 结束 属性 公共 属性 Volume() As 整数 获取 返回 _VolumeBar.Volume 结束 获取 设置(Val As 整数) _VolumeBar .Volume = Val Invalidate() 结束 设置 结束 属性i尝试减少SetVolume增加音量。 MediaPlayerVolume1.SetVolume = MediaPlayerVolume1.Volume TxtVolume.Text = Trim(-10000 * MediaPlayerVolume1.SetVolume / 100 )
我使用TxtVolume.Text进行测试,检查是否有效。
解决方案获得0到100的读数,乘以-100。
0 - > 0 1 - > -100 ... 100 - > -10000如果你需要它反转,那么得到你的0到100读数,乘以100并从10000减去它:
0 - > -10000 1 - > -9900 ... 100 - > 0
哦,你去了,谢谢你们的数学解决方案,@ Richard MacCutchan我尝试了你的解决方案,我做的是设置进度条最大值为10000,它看起来像这样: MediaPlayerVolume1.SetVolume = MediaPlayerVolume1.Volume TxtVolume.Text = Trim(-10000 +( 100 * 100 ) - 10000 + MediaPlayerVolume1.SetVolume)
随着你的数学工作,我想要你的大脑哥们:) 非常感谢你帮助我。
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:
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 Propertyi tried to decrease SetVolume when i increase Volume.
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.
解决方案 Get your 0 to 100 reading, multiply it by -100. 0 -> 0 1 -> -100 ... 100 -> -10000If 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 -> 0Oh 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: 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.
更多推荐
如何通过增加其他价值来减少价值
发布评论