在 vb.net 中使用 ANSI 代码

working with ansi codes in vb.net

我在编写学校程序时遇到了一个问题 运行,该程序将 abc 之类的字符串转换为 bcda 变为 b b 变为 c,您可以看到其余部分。

For i = 0 To length - 1
    If (Asc(justatext.Substring(i, 1)) >= 65 And Asc(justatext.Substring(i, 1)) <= 90) Then
        Asc(justatext.Substring(i, 1) = (Asc(justatext.Substring(i, 1) + 1)))
        answer &= justatext.Substring(i, 1)
    End If
Next

这是一个函数,我 return 值 answer,但我总是得到一个 invalid cast exception。有没有一种方法可以用 ansi 代码做到这一点?

你的问题在括号里,你的问题挺多的,估计是你把自己搞糊涂了。

我已经检查了你的代码并删除了不需要的括号:

    For i = 0 To justatext.Length - 1
        If Asc(justatext.Substring(i, 1)) >= 65 And Asc(justatext.Substring(i, 1)) <= 90 Then
            answer &= Chr(Asc(justatext.Substring(i, 1)) + 1)
        End If
    Next

注意:此代码仅适用于大写字母..