我请求您的帮助,以便能够在 Windows 控制台中读取这些符号。
Imports System.Text
Module Module1
Sub Main()
Dim userInput = New StringBuilder()
Dim maxLength = 10
While True
' Read, but don't output character
Dim cki As ConsoleKeyInfo = Console.ReadKey(True)
Select Case cki.Key
Case ConsoleKey.Enter
' Done
Exit While
Case ConsoleKey.Backspace
' Last char deleted
If userInput.Length > 0 Then
userInput.Remove(userInput.Length - 1, 1)
Console.Write(vbBack & " " & vbBack)
End If
Case Else
' Only append if less than max entered and it's a display character
If userInput.Length < maxLength AndAlso Not Char.IsControl(cki.KeyChar) Then
userInput.Append(cki.KeyChar)
Console.Write(cki.KeyChar)
End If
End Select
End While
MsgBox("'" & userInput.ToString() & "'")
End Sub
End Module
我刚刚安装了 Visual Studio 2019 并粘贴了代码来测试新程序,令我惊讶的是,我遇到了无法读取 Ñ 和 Ó 的问题。我不知道发生了什么,如何解决它并防止它再次发生。
这很奇怪,我知道代码应该可以工作(它在我以前的 PC 上工作过),但现在不行;当我尝试时,只会出现问号。
从 Win7 和 VS 2015 更改为 Win10 和 VS 2019,我的新 PC 可能缺少什么?
我提前感谢您的帮助。