我在程序中实现加载栏,以便在用户在数据库中完成问题时显示完成进度。我试图为加载栏保留一个有效值,这样当有人完成一个问题时,加载栏就会填满一点。
我试图允许来自整个系统的值使用并更改百分比条的值,我使用公共类来保存计算百分比的所有值。
"' WindowsApplication1.Percentage'的类型初始值设定项抛出异常。"是我收到的唯一错误消息。
当我尝试加载包含加载栏的表单时,系统崩溃。有人可以提供一些关于我做错的信息吗? 谢谢。
Private Sub HomeScreenToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles HomeScreenToolStripMenuItem.Click
HomeScreen.Show()
Me.Close()
End Sub
Private Sub LogOffToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles LogOffToolStripMenuItem.Click
Start_Screen.Show()
Me.Close()
End Sub
Private Sub ExitToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles ExitToolStripMenuItem.Click
End
End Sub
Private Sub SFLink_LinkClicked(sender As System.Object, e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles SFLink.LinkClicked
End Sub
Private Sub NumbersMenu_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
ProgressBar1.Value = Percentage.Percentage
End Sub
End Class
Public Class Percentage
Public Shared Percentage As Integer = (QuestionCompletion / QuestionCount) * 100
Public Shared QuestionCompletion As Integer = 5
Public Shared QuestionCount As Integer = 100
'The values for QuestionCompletion and QuestionCount are here for testing at the moment
End Class
答案 0 :(得分:0)
尝试将Percentage设为只读属性
Public Shared ReadOnly Property Percentage
Get
Return (QuestionCompletion / QuestionCount) * 100
End Get
End Property