VB 2005 Forms Control

Can some one help me how to make a textbox accept only numeric values. The code "textbox1.numeric=true" gives an error

thanks



Answer this question

VB 2005 Forms Control

  • bsmucker

    hello,

    thanks for the reply. I tried MTBox, not that effective. Well, I got some other code to ckeck the value programmatically.

    amou


  • Robert Bruckner MSFT

    Two such threads on this

    http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=218113&SiteID=1
    http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=218028&SiteID=1

    And the code to make a textbox accept numbers only

    Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
    ' textbox1 just accept numeric data
    If Char.IsNumber(e.KeyChar) or Or Char.IsControl(e.KeyChar) Then
    e.Handled = False
    Else
    MessageBox.Show("plz click numbers only")
    e.Handled = True
    End If
    End Sub


  • Pawel.Gr

    That's because there is no such property. You can use a masked text box, or you can search there forums, where the code to accept only numbers and control chars has been posted may times.



  • aaron222

    Dear Sir,

    Please, help me about use of multi page controls in vb.

    I was tried to insert multi page control into forms with two page, draw a textbox1 into page1 and second one into listbox now i want to set to property for textbox and listbox. i could not set to this.

    please tell me how is it.


    Rashesh



  • Jaxbeachess

    thank you

    amou


  • VB 2005 Forms Control