PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: WM_CHAR  (Read 143 times)

Petrus Vorster

  • FireFly3 Registered User
  • Senior FireFly Member
  • *
  • Posts: 361
WM_CHAR
« on: December 02, 2017, 04:39:37 PM »

I have used this simple formula under WM_Char to prevent the user from pressing certain keys:
Code: [Select]
elect Case Chr$(chCharCode)
        Case "A" To "Z" ,"a" To "z", Chr$(9), Chr$(8), Chr$(32)
           
            Function = 0 '
           
        Case Else
            Function = 1
               
            Exit Function
    End Select   
   Function = 0 

I want to limit it to certain places in the string to prevent TYPO's on capturing tracking numbers manually.
It has to be TWO LETTERS, 9 Numbers, 2 Letters: e.g.
RA952800068ZA

Thereafter i will pass the string for validation using a check digit, but how to get it to only allow characters only in that sequence i am still struggling to make happen although i am pretty sure it would happen inside the same function.

Anny ideas would be appreciated!
Logged

David Kenny

  • FireFly3 Registered User
  • Senior FireFly Member
  • *
  • Posts: 437
  • Windows 7
Re: WM_CHAR
« Reply #1 on: December 02, 2017, 10:36:17 PM »

Are you talking about forcing that sequence as the user types?  That could get frustrating for the user.  How would you want to deal with them cursoring back with the arrow keys and then deleting the first A, shifting the 9 into a letter position?  It's probably best to check when they leave the field.  Too many possible ways of dealing with this that without knowing how you want to notify the user and when (in great detail) there is really no way to offer advice.
Logged

Petrus Vorster

  • FireFly3 Registered User
  • Senior FireFly Member
  • *
  • Posts: 361
Re: WM_CHAR
« Reply #2 on: December 03, 2017, 06:38:49 AM »

Hi David

Yes, i was thinking of enforcing the sequence although i still do a check when the textbox loses focus.
That tracking numbers has to be in that exact sequence.
I was using the tool myself and i had a barcode scanner, but now that some other guys are going to use it, and they will not all have barcode scanners, i discovered how easy one makes typing errors, and how frustrating it is to get a pop-up, reminding you its wrong.

Paul uses something like that in his DATE function in the Fire-Textbox, but it's ok, It's not the en of the world.

thanks for the advice.
Logged

Nathan Durland

  • FireFly3 Registered User
  • Junior FireFly Member
  • *
  • Posts: 82
Re: WM_CHAR
« Reply #3 on: December 03, 2017, 09:56:56 AM »

I did a quick search on the PowerBASIC board for "masked input".  Most advanced database system have this for entering things like phone numbers and so forth.  I got several hits, but I admit I didn't study them too hard.  Most are for enforcing entering only numbers, but at least one was a sub class example that might be adapted to your needs. 
Logged

David Kenny

  • FireFly3 Registered User
  • Senior FireFly Member
  • *
  • Posts: 437
  • Windows 7
Re: WM_CHAR
« Reply #4 on: December 05, 2017, 02:28:58 AM »

I thought about it again, and came up with something you might like. Three different edit fields almost touching each other.  The outer ones only allow alpha, and the inner only digits.  I would intercept arrow keys to allow the user to seamlessly move from one field to the other as if they were one, although I wouldn't make the borders invisible so that the user has a reminder what size each piece is.  It would look much nicer if the fonts are fixed width.
Logged