作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试在 VB.NET 中为一个学校项目构建一个囚徒困境游戏,但我发现这种奇怪的行为我不明白。
我有 2 个用于播放器的按钮,“Co-op”和“Defect”都具有相同的代码结构:
Private Sub btnDefect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDefect.Click
Oponent()
MovePlayer = "Defect"
If MoveOponent = "Coop" Then
scorePlayer += 50
scoreOponent -= 50
Else
If MoveOponent = "Defect" Then
scorePlayer -= 10
scoreOponent -= 10
End If
End If
scores()
End Sub
Could not copy the file "obj\x86\Debug\PrisonersDilemma.exe" because it was not found. PrisonersDilemma
Public Class Form1
Dim MovePlayer As String
Dim MoveOponent As String
Dim scorePlayer As Integer
Dim scoreOponent As Integer
Sub scores()
lblscoreOponent.Text = scoreOponent
lblscorePlayer.Text = scorePlayer
End Sub
Sub Oponent()
If MovePlayer = "" Then
MoveOponent = "Coop"
Else
MoveOponent = MovePlayer
End If
lblMoveOponent.Text = MoveOponent
lblMoveOponent.Visible = True
End Sub
Private Sub btnCoop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCoop.Click
Oponent()
MovePlayer = "Coop"
If MoveOponent = "Coop" Then
scorePlayer += 10
scoreOponent += 10
Else
scorePlayer += 50
scoreOponent -= 50
End If
scores()
End Sub
Private Sub btnDefect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDefect.Click
Oponent()
MovePlayer = "Defect"
If MoveOponent = "Coop" Then
scorePlayer += 50
scoreOponent -= 50
Else
If MoveOponent = "Defect" Then
scorePlayer -= 10
scoreOponent -= 10
End If
End If
scores()
End Sub
End Class
最佳答案
1:编译时,如果出现错误,你的bin文件夹下的EXE不会被替换。您的 EXE 是最后一次成功的构建,这就是为什么您会收到这样的问题:“构建过程中出现错误,您要运行最后一次成功的构建吗?”如果你说是,这将运行该 EXE。
2:似乎我在 2012 中有时会看到“找不到”错误,我认为这是 Visual Studio 的问题。通常我会再试一次,这很好。如果您从 bin 文件夹运行 EXE,请确保在编译之前它没有运行。它将阻止复制它的能力。
3:如果您需要帮助找出出现编译错误的原因,您必须显示该代码,而不是有效的代码!
关于vb.net - VB.NET 中的囚徒困境 - 与 "Else If"相关的编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19508451/
我是一名优秀的程序员,十分优秀!