我是编码的新手,实际上不知道为什么在此代码行的底行中,为什么要在底行显示一条消息“期望声明”greenCount
。该代码几乎解释了我想要什么,但无论如何,我有三个变量totalCount
,redCount
和greenCount
。
的值greenCount
应totalCount
减去redCount
。有人可以帮忙吗?
Public Class Form1
Dim totalCount As Integer = 44
Dim redCount As Integer
Dim greenCount As Integer greenCount = totalCount - redCount
编译器期望greenCount = totalCount - redcount
在Sub或Function内部。那是它认为丢失的“声明”。
您需要更多类似的东西来使编译器保持快乐...
Module Program
Sub Main(args As String())
Dim f As New Form1
Call f.ChangeGreenCount(42)
End Sub
End Module
Public Class Form1
Dim totalCount As Integer = 44
Dim greenCount As Integer
Public Sub ChangeGreenCount(redCount As Integer)
greenCount = totalCount - redCount
End Sub
End Class
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句