Ensuring a user won't input a string when single is expected...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shadowbeam
    New Member
    • Mar 2008
    • 3

    Ensuring a user won't input a string when single is expected...

    Im making a program which works with singles.

    I want to ensure when they input data into an inputbox
    they don't enter a string or letter - and provide my own erroe message

    The val and isnumeric functions seem to be a good choice.
    having difficulties though

    help appreciated
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    You need to check the data for the proper format and reprompt if format is wrong.

    Comment

    • shadowbeam
      New Member
      • Mar 2008
      • 3

      #3
      Apologies, I've been coding for half a year now in VB

      Not thoroughly certain with all the functions. My knowledge is very limited.

      Could you please give me an example?

      Comment

      • Killer42
        Recognized Expert Expert
        • Oct 2006
        • 8429

        #4
        What version of VB are you using?

        Also, in general I would discourage the use of InputBox() function. You really should create your own user interface, as InputBox doesn't allow enough control over what the user does. Probably the ideal control to use for your own input handling would be the MS Masked Edit control. This is like a text box, but allows you to control what will be accepted.

        Comment

        • shadowbeam
          New Member
          • Mar 2008
          • 3

          #5
          Its an old version. Computers at my school are really old.
          Running windows 2000

          Comment

          • Killer42
            Recognized Expert Expert
            • Oct 2006
            • 8429

            #6
            Originally posted by shadowbeam
            Its an old version. Computers at my school are really old.
            Running windows 2000
            My guess would be VB6 or VB5, then.

            In any case, the Masked Edit control will provide you much better control over input, as I said. Otherwise, can you tell us what "difficulti es" you're experiencing using the Val() function and so on?

            Comment

            Working...