关于maskedit的问题(20分)

G

grass1

Unregistered / Unconfirmed
GUEST, unregistred user!
我想使用Maskedit来显示+9.99到-9.99之间的数字,
请问Maskedit的Input Mask要怎么写啊?我试了半天,不行啊。
 
这样:
在 MaskEdit 中输入 !#9.99
但这样还不够,需要在 MaskEdit 的 OnChange 事件中加入:
代码:
  If (Copy(MaskEdit1.EditText, 1, 1) <> '-') Then
    MaskEdit1.EditText := '__.__';
 
上面的语句是什么意思?
是不是判断正负,如果为正,就不显示正号?
 
不行啊,可能是因为我还要和SpinButton1联合起来用,
能够实现加减的功能,老是报错,内容如下:
project raised exception class EConvertError with
message''' is not a valid floating point value.process stopped.
Use step or run to continue.
 
稍稍改一下
在 OnKeyUp 事件中写
If (Copy(MaskEdit1.EditText, 1, 1) <> '-') and (Copy(MaskEdit1.EditText, 1, 1) <> '+')Then
MaskEdit1.EditText := '_' + Copy(MaskEdit1.EditText, 2, 4);
就可以了。
 

Similar threads

顶部