在 Visual Basic 中按 Enter 键输入数据时如何不退出控制台

how not to exit the console when entering data pressing Enter in Visual Basic

这是代码。我基本上想要的是用户键入一个数字,按 Enter 键并读取该数字以便使用它。不知道控制台退出是因为按了回车键还是其他原因

Sub CompruebaNumeroPrimo()
        Console.Write("Función que comprueba si un nº es primo, introduce el nº")
        Console.WriteLine()
        Dim NumeroAComprobar As Integer = CType(Console.ReadLine(), Integer) 
        Dim RestosCero As Integer = 0
        For Indice As Integer = 1 To NumeroAComprobar
            If (NumeroAComprobar Mod Indice = 0) Then
                RestosCero += 1
            End If
        Next Indice
        If (RestosCero > 2) Then
            Console.Write("No es primo")
        Else
            Console.Write("Es primo")
        End If
        Console.WriteLine()
    End Sub

最后使用console.read()。消息 press any key to exit 。这将阻止控制台退出。