Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

how do I do this?

how can i make it so when someone does enter text into a text box it will give an error message, even if they press the space bar? thanx for any help -cap'n krunch


Comments

  • : how can i make it so when someone does enter text into a text box it will give an error message, even if they press the space bar? thanx for any help -cap'n krunch


    Just use the key down event. Maybe something like this:

    Sub text1_KeyDown()

    MsgBox ("This is an error")

    End Sub


    If you want to prevent anybody from entering data into the text box then you can just set the enabled property to false.

    HTH

    Albert




  • If you need to be able to scroll through the text and don't have the "Locked" property:


    Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)


    MsgBox "You can't do that!"

    KeyCode = 0 'To prevent the key from altering the text.

    End Sub


    Sub Text1_Change()


    If Text1.Text <> OriginalText Then

    MsgBox "You can't do that!"

    Text1.Text = OriginalText

    End If


    End Sub


    If you need to be able to scroll through the text and do have the "Locked" property:


    Text1.Locked = True


    If you need to be able to scroll through the text and don't have the "Locked" property and don't ever use the textbox to let people enter info:


    You can download my ScrollLbl.ocx from my web page.


    It has a caption limit of 28,000 bytes.

    It's not perfect, but it comes in handy.




  • Chris BrownChris Brown USAMember Posts: 4,624 ✭✭

    __ { http://forcoder.org } free video tutorials and ebooks about / JavaScript, Visual Basic, Scratch, Go, PHP, Assembly, C++, C, Ruby, Python, Objective-C, Perl, Swift, Java, R, PL/SQL, Visual Basic .NET, MATLAB, C#, Delphi Transact-SQL, ML, Lua, Crystal, Kotlin, Scala, Ada, Hack, Erlang, LabVIEW, Logo, ABAP, FoxPro, Lisp, SAS, Clojure, Fortran, Prolog, Dart, F#, Bash, Apex, Scheme, VBScript, D, Alice, COBOL, Awk, Rust, Julia / _____________

Sign In or Register to comment.