如何通过我的进度条防止因无效值而导致崩溃? [英] How do I prevent crashing because of invalid value with my progress bar?

查看:54
本文介绍了如何通过我的进度条防止因无效值而导致崩溃?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿那里,感谢你花时间阅读这篇文章,我正在开发一款游戏并遇到另一个问题,我已经完成了游戏中的所有内容,但是水平系统。我做了这段代码,以确保当进度条超过最大值时它不会崩溃:

 ' 每次点击都会慢慢提高等级 
如果 Stats.ProgressBar1.Value = 100 然后 MsgBox( 您已准备好升级!其他
如果 Stats.ProgressBar1.Value< = 100 然后 Stats.ProgressBar1.Value = Stats.ProgressBar1.Value + 2
如果 Stats.ProgressBar1.Value> = 100 然后 Stats.ProgressBar1.Value = 100



但它只是冻结了,有人可以告诉我如何做到这一点或其他方式吗? :)

解决方案

尝试:

 如果 Stats.ProgressBar1.Value =  100  然后 
MsgBox( 您已准备好升级!
其他
Stats.ProgressBar1.Value = Math.Min( 100 ,Stats.ProgressBar1.Value + 2


Hey there , thanks for taking your time to read this , I am developing a game and ran into another problem , I am done with everything in my game but the level system. I did this code to make sure it doesn't crash when the progressbar goes over the maximum value:

'Increases Level by every click slowly
        If Stats.ProgressBar1.Value = 100 Then MsgBox("You are ready to level up!") Else 
        If Stats.ProgressBar1.Value <= 100 Then Stats.ProgressBar1.Value = Stats.ProgressBar1.Value + 2
        If Stats.ProgressBar1.Value >= 100 Then Stats.ProgressBar1.Value = 100


But it just freezes up instead , Can someone please tell me how to do this or another way to do it? :)

解决方案

Try:

If Stats.ProgressBar1.Value = 100 Then
   MsgBox("You are ready to level up!")
Else
   Stats.ProgressBar1.Value = Math.Min(100, Stats.ProgressBar1.Value + 2)


这篇关于如何通过我的进度条防止因无效值而导致崩溃?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆