我在VB.NET中的代码不断响应构建错误,但是Visual Studio 2017没有检测到任何错误。
我收到的回复是:
存在构建错误。您要继续并运行上一次成功的构建吗?
然后,我收到一个错误代码:
1> ------构建开始:项目:游戏,配置:调试任何CPU ------ 1> C:\ Users \ SAMSUNG \ source \ repos \ Game \ Game \ Game.vb(48,29):错误BC37234:当前项目类型不支持非结构化异常处理。 1>完成的建筑项目“ Game.vbproj”-失败。 ===========构建:0成功,1失败,0最新,跳过0 ==========
这是我的代码
Imports System
Module Module1
Sub Main()
Dim Choice1 As Integer = 0
Dim rng As New Random
Dim strmod As Integer = 1
Dim yourhit As Integer
Dim revenge As Integer
Dim Health As Integer = 5
Console.WriteLine("Menu")
Console.WriteLine("-----")
Console.WriteLine("1.Training")
Console.WriteLine("2.Battle")
Choice1 = Console.ReadLine()
For count = 1 To 10
If Choice1 = 1 Then
Console.BackgroundColor = ConsoleColor.DarkBlue
Console.ForegroundColor = ConsoleColor.DarkCyan
Console.Clear()
Console.WriteLine("Welcome to the training grounds!")
Console.WriteLine("Press Key to hit!")
Console.ReadKey()
For counter = 1 To 10
yourhit = (rng.Next(1, 10) + strmod)
Console.WriteLine("You hit the dummy and deal {0} damage to it!", yourhit)
Console.ReadKey()
Next
ElseIf Choice1 = 2 Then
Console.BackgroundColor = ConsoleColor.DarkBlue
Console.ForegroundColor = ConsoleColor.DarkCyan
Console.Clear()
yourhit = (rng.Next(1, 10) + strmod)
revenge = (rng.Next(1, 10) + strmod)
Console.WriteLine("A Soldier has ambushed you!")
Console.WriteLine("Press Key to Fight Back!")
For counter = 1 To 10
Console.ReadKey()
If yourhit > revenge Then
Console.WriteLine("You hit the soldier and do {0} damage to him!", yourhit)
ElseIf yourhit < revenge Then
Health = Health - revenge
If Health <= 0 Then
Console.BackgroundColor = ConsoleColor.Black
Console.ForegroundColor = ConsoleColor.Red
Console.Clear()
Console.WriteLine("YOU DIED!")
Console.ReadKey()
End
Else
Console.WriteLine("The soldier hit you and dealt {0} damage to you!", revenge)
End If
Else
Console.WriteLine("He blocked your attack!")
End If
Console.ReadKey()
Next
Else
Console.WriteLine("Please enter 1 or 2 only...")
End If
Next
End Sub
End Module