Re: [Gambas-user] MaskBox.Mask

2014-05-06 Thread Patrik Karlsson
Thank you for your input.
I will keep my code since I prefer the protection for CTRL-V over the
optimization for a very short string.
However, the _KeyPress and Stop Event will come in handy in another place,
thanks!

/Patrik


2014-04-27 16:26 GMT+02:00 Tobias Boege tabo...@gmail.com:

 On Sat, 26 Apr 2014, Patrik Karlsson wrote:
  Hi,
 
  today I am using TextBox_Change event to reject | characters.
 
  Public Sub txtName_Change()
 
If String.InStr(Last.Text, |)  0 Then
  Last.Text = Replace(Last.Text, |, )
Endif
 
  End
 
  I guess MaskBox can do this much simplier, but how, what Mask?
 

 No, MaskBox is there to force formatted input. But the Mask property is way
 weaker than regular expressions. The main point is that you can only
 describe fixed-length strings (plus/minus the finite number of #/9 fields
 in your Mask). So wherever you want to forbid |, you would write [^|]
 but that also consumes any character but |. So you cannot accept
 arbitrary
 strings but only strings of a length equal to the times you forbid the |
 character.

 Your initial approach was much better but one thing: if you use InStr()
 each
 time the TextBox changes, you will scan the whole contents each time they
 change but you only want to capture inputs, right? If you tell your user
 not
 to use Ctrl-V or stuff, you can do:

 Public Sub txtName_KeyPress()
   If Key.Text = | Then Stop Event
 End

 Regards,
 Tobi

 --
 There's an old saying: Don't change anything... ever! -- Mr. Monk


 --
 Start Your Social Network Today - Download eXo Platform
 Build your Enterprise Intranet with eXo Platform Software
 Java Based Open Source Intranet - Social, Extensible, Cloud Ready
 Get Started Now And Turn Your Intranet Into A Collaboration Platform
 http://p.sf.net/sfu/ExoPlatform
 ___
 Gambas-user mailing list
 Gambas-user@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/gambas-user

--
Is your legacy SCM system holding you back? Join Perforce May 7 to find out:
#149; 3 signs your SCM is hindering your productivity
#149; Requirements for releasing software faster
#149; Expert tips and advice for migrating your SCM now
http://p.sf.net/sfu/perforce
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] MaskBox.Mask

2014-04-27 Thread Tobias Boege
On Sat, 26 Apr 2014, Patrik Karlsson wrote:
 Hi,
 
 today I am using TextBox_Change event to reject | characters.
 
 Public Sub txtName_Change()
 
   If String.InStr(Last.Text, |)  0 Then
 Last.Text = Replace(Last.Text, |, )
   Endif
 
 End
 
 I guess MaskBox can do this much simplier, but how, what Mask?
 

No, MaskBox is there to force formatted input. But the Mask property is way
weaker than regular expressions. The main point is that you can only
describe fixed-length strings (plus/minus the finite number of #/9 fields
in your Mask). So wherever you want to forbid |, you would write [^|]
but that also consumes any character but |. So you cannot accept arbitrary
strings but only strings of a length equal to the times you forbid the |
character.

Your initial approach was much better but one thing: if you use InStr() each
time the TextBox changes, you will scan the whole contents each time they
change but you only want to capture inputs, right? If you tell your user not
to use Ctrl-V or stuff, you can do:

Public Sub txtName_KeyPress()
  If Key.Text = | Then Stop Event
End

Regards,
Tobi

-- 
There's an old saying: Don't change anything... ever! -- Mr. Monk

--
Start Your Social Network Today - Download eXo Platform
Build your Enterprise Intranet with eXo Platform Software
Java Based Open Source Intranet - Social, Extensible, Cloud Ready
Get Started Now And Turn Your Intranet Into A Collaboration Platform
http://p.sf.net/sfu/ExoPlatform
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


[Gambas-user] MaskBox.Mask

2014-04-25 Thread Patrik Karlsson
Hi,

today I am using TextBox_Change event to reject | characters.

Public Sub txtName_Change()

  If String.InStr(Last.Text, |)  0 Then
Last.Text = Replace(Last.Text, |, )
  Endif

End

I guess MaskBox can do this much simplier, but how, what Mask?

/Patrik
--
Start Your Social Network Today - Download eXo Platform
Build your Enterprise Intranet with eXo Platform Software
Java Based Open Source Intranet - Social, Extensible, Cloud Ready
Get Started Now And Turn Your Intranet Into A Collaboration Platform
http://p.sf.net/sfu/ExoPlatform
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user