hexagon logo

VB code for Form EventClick

I created a form that has the CMM Operators enter in their information at the beginning of a program. Since some of this information is used for filenames, I do not want to allow special characters. In the EventClick section of the Continue button, I added this code...

Dim s As String
Set s = EditBox1.Text
If InStr(s,"*") = 0 Then

MsgBox "hello"

End If


...I get an error message each time I try it. I did this for testing so I only included "*" but finalized I would like to check if the edit boxes contain "\ / : * ? " < > |" if it does, then display a message and not let them continue until it is fixed. Anyone have any ideas?
Thanks again for the help.
Parents
  • You can capture at key press.

    It's been a while, but in the text box for the keypress event, evaluate the ASCII code in a Select statement.

    Select Keyascii
    Case (all the ascii codes you want to allow)
    Case Else
    Keyascii=""
    End case

    You can even throw a counter in there for dashes (only one allowed) and periods (likewise)

    EDIT: As I recall now, I think it's actually a key down event
Reply
  • You can capture at key press.

    It's been a while, but in the text box for the keypress event, evaluate the ASCII code in a Select statement.

    Select Keyascii
    Case (all the ascii codes you want to allow)
    Case Else
    Keyascii=""
    End case

    You can even throw a counter in there for dashes (only one allowed) and periods (likewise)

    EDIT: As I recall now, I think it's actually a key down event
Children
No Data