0
Private Sub txtInput_KeyPress(ByVal sender As Object, ByVal e As    System.Windows.Forms.KeyPressEventArgs) Handles txtInput.KeyPress

Dim len As Integer

 len = txtCode.Text.Length

If (Asc(e.KeyChar) = 65 Or Asc(e.KeyChar) = 97) Then

        txtCode.Text += "Acer" & " "

    ElseIf (Asc(e.KeyChar) = 66 Or Asc(e.KeyChar) = 98) Then
        txtCode.Text += "King" & " "

    ElseIf (Asc(e.KeyChar) = 8) Then
        Try
            txtCode.Text = txtCode.Text.Remove(len - 4, len)
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
     End If

     End Sub

我没有发布图片的权限,所以请考虑一下

我想从第一个文本框中删除“b”,我应该从第二个文本框中删除“King”每个单词的长度相同“Acer”“King”长度始终为 4

但我收到以下错误

“索引和计数必须引用字符串中的位置。参数名称:计数”

我还尝试用另一个变量dim c替换“len-4”作为整数=len-4

4

1 回答 1

0
textbox2.text = left(textbox2.text,len(textbox2.text)-4)

这基本上从textbox2.

于 2012-05-20T18:31:55.577 回答