有人能帮我修改一下吗?
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;
}
}
}
}
}
我添加了
this->textBox1->KeyPress += gcnew System::Windows::Forms::KeyPressEventHandler(this, &MyForm::textBox_KeyPress);
#pragma region Windows Form Designer generated code
void InitializeComponent(void)