0

有人可以为我修改吗?

Private Sub NumericKeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
        If e.KeyChar = Chr(Keys.Back) Then
        Else
            If Not Char.IsDigit(e.KeyChar) Then
                e.Handled = True
                Beep()
            Else
                If Len(TextBox1.Text) > 0 Then
                    If Val(TextBox1.Text) > 105097565 Then
                        e.Handled = True
                        Beep()
                    End If
              End If
                    End If
         End If
    End Sub

或者告诉我是怎么回事: 1.NumericKeyPress 事件?2.e.KeyChar怎么说?3.IsDigit怎么说?4.Chr(ASCII码)怎么说?5.如何处理e.Key?6.如何系统提示音?

我试过:

private: System::Void textBox1_KeyPress( Object^ sender, System::Windows::Forms::KeyPressEventArgs^ e )
                {
                    if(e->KeyChar == (Char)8)
                    {}
                    else 
                    {
                    if (!Char::IsDigit(e->KeyChar))
                    {
                    e->Handled = true;
                    }
                    else
                    {
                    if (textBox1->Text->Length > 0)
                    {
                    if (int::Parse(textBox1->Text) > 105097565)
                    {
                    e->Handled = true;
                    }
                    }
                    }
                    }
                 } 

但它没有用。

4

1 回答 1

0

我添加了

this->textBox1->KeyPress += gcnew System::Windows::Forms::KeyPressEventHandler(this, &MyForm::textBox_KeyPress);

#pragma region Windows Form Designer generated code
        void InitializeComponent(void)
于 2013-03-01T22:07:42.717 回答