Vb.net 使用全局变量在进度条上显示值

Vb.net 使用全局变量在进度条上显示值,vb.net,variables,module,progress-bar,vb.net-2010,Vb.net,Variables,Module,Progress Bar,Vb.net 2010,我正在用VisualBasic2010制作一个游戏,除了在使用全局变量方面遇到的一个问题外,我几乎已经完成了它。我在模块中设置了它们,如下所示: Module Module1 Public Structure Maths Public accuracy As Integer Public speed As Integer Public vision As Integer End Structure Public Mathsprogress As Maths End Mo

我正在用VisualBasic2010制作一个游戏,除了在使用全局变量方面遇到的一个问题外,我几乎已经完成了它。我在模块中设置了它们,如下所示:

Module Module1
Public Structure Maths
    Public accuracy As Integer
    Public speed As Integer
    Public vision As Integer
End Structure

Public Mathsprogress As Maths
End Module
我试图用这些变量在一个表单中使用它们来存储值,这样我就可以将这些值转移到另一个表单中。为此,我创建了嵌套的if语句,根据“不正确”的值设置变量
mathsprogress.accurity=x的值

  '''''''''''CONTINUED''''''''''''''''''

 Else : incorrect = incorrect + 1


        If incorrect = 0 Then
            Mathsprogress.accuracy = 10
        ElseIf incorrect < 2 And incorrect > 0 Then
            Mathsprogress.accuracy = 9
        ElseIf incorrect = 3 Then
            Mathsprogress.accuracy = 8
        ElseIf incorrect = 4 Then
            Mathsprogress.accuracy = 7
        ElseIf incorrect = 5 Then
            Mathsprogress.accuracy = 6
        ElseIf incorrect = 6 Then
            Mathsprogress.accuracy = 5
        ElseIf incorrect = 7 Then
            Mathsprogress.accuracy = 4
        ElseIf incorrect = 8 Then
            Mathsprogress.accuracy = 3
        ElseIf incorrect = 9 Then
            Mathsprogress.accuracy = 2
        Else
            Mathsprogress.accuracy = 1
        End If

    End If
我知道变量的设置是正确的,因为当我在第一个表单的表单加载范围内设置mathsprogress.accurity=10时,变量就起作用了。我的问题可能在于我把IF语句块放在了哪里,有人能解释一下吗


谢谢

您是否有可能在范围内的其他地方进行声明的Mathsprogress?或者是否有其他代码为准确性赋值?也可能是事件发生的顺序。第一个块可以简化为一个简单的赋值,如
Mathsprogress.accurity=(10-不正确)
。。。但2个不正确未被解释。您是否可能在范围内的其他地方声明Mathsprogress?或者是否有其他代码为准确性赋值?也可能是事件发生的顺序。第一个块可以简化为一个简单的赋值,如
Mathsprogress.accurity=(10-不正确)
。。。但2项不正确未被考虑在内
 Private Sub pbaccuracy_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles pbaccuracy.Click
    pbaccuracy.Value = Mathsprogress.accuracy
End Sub