Turn on thread page Beta
    • Thread Starter
    Offline

    0
    ReputationRep:
    hey!

    I need help with my VB programme! I was wondering if any of you guys know how to validate a text box?

    I need to validate a text box so it only excepts numbers.

    Thanks
    Riffy
    Offline

    14
    ReputationRep:
    (Original post by Riffy)
    hey!

    I need help with my VB programme! I was wondering if any of you guys know how to validate a text box?

    I need to validate a text box so it only excepts numbers.

    Thanks
    Riffy
    use either the _validate event or _lostfocus

    then put this in it

    if Not IsNumeric(text1.text) THen
    Msgbox("Must be numeric")
    text1.setfocus
    end if
    Offline

    2
    ReputationRep:
    alternatively, you could say:

    Private Sub txtText1_KeyPress(KeyAscii As Integer)
    Select Case KeyAscii
    Case 48 To 57, 8 'allows numbers and backspace
    Case Else
    KeyAscii = 0
    MsgBox "Please Enter a Number"
    End Select
    End Sub
    • Thread Starter
    Offline

    0
    ReputationRep:
    Cheers m8 that was Gr8!
    The piece of code my professor gave me was atleast 5 lines!!

    Anyway you studying the same course as me? (Advanced VCE in ICT)

    I'm aiming for an A in Visual Basic, the professor told me that the programme that i have made is at a A grade but it all depends on my documentation!

    Once again i thank you kind person
    • Thread Starter
    Offline

    0
    ReputationRep:
    Thanx but the 1st one makes more sense
    hehehe
    thanx anyway!
 
 
 

University open days

  1. University of Edinburgh
    All Departments Undergraduate
    Sat, 22 Sep '18
  2. University of Exeter
    Undergraduate Open Days - Penryn Campus Undergraduate
    Sat, 22 Sep '18
  3. Loughborough University
    General Open Day Undergraduate
    Sat, 22 Sep '18
Poll
Which accompaniment is best?

The Student Room, Get Revising and Marked by Teachers are trading names of The Student Room Group Ltd.

Register Number: 04666380 (England and Wales), VAT No. 806 8067 22 Registered Office: International House, Queens Road, Brighton, BN1 3XE

Write a reply...
Reply
Hide
Reputation gems: You get these gems as you gain rep from other members for making good contributions and giving helpful advice.