# 我想,可以这么做

Posted by joseph on August 15, 1998 at 11:44:46:

In Reply to: Re: 本人亦遇到相同问题 posted by won on August 09, 1998 at 16:07:51:

我想,可以这么做:(以你的问题而言)
设定MaskEdBox1的Format=#,##0.00
Mask=#,###.##
PromptInclude=False

Private Sub MaskEdBox1_KeyDown(KeyCode As Integer, Shift As Integer)
Dim TmpZero As Integer

If KeyCode = 190 Or KeyCode = 110 Then
TmpZero = LeftLength - Len(MaskEdBox1) 'LeftLength 为整数位数(不含",")
MaskEdBox1 = String(TmpZero, "0")& MaskEdBox1
SendKeys "{RIGHT 6}"
'6 为小数点以左总长(包括小数点)
End If
End Sub

最后,如此获得Mask输入值:
Val(Mid(MaskEdBox1, 1, LeftLength) & "." & Mid(MaskEdBox1, LeftLength + 1, RightLength))
'RightLength 为小数位数

Follow Ups: