以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  格式判断  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=128736)

--  作者:qaz17909
--  发布时间:2018/12/13 22:02:00
--  格式判断

两列,一列列名是“数值“,为字符型,另外一列列名“显示值”,为双精度小数,datacolchanged事件如下

Select Case e.DataCol.name
    Case "数值"
        e.DataRow("显示值") = Format(CDbl(e.NewValue),"0.00")
End Select

当数值列输入无法转化的格式时,会报错,例如数值列输入“0..10”或者“0.10.”

可否先判断该值的格式是否可以转化,如果不能转化,弹出自定义的对话框


--  作者:有点甜
--  发布时间:2018/12/13 23:14:00
--  

参考

 

http://www.foxtable.com/webhelp/scr/0324.htm

 


--  作者:qaz17909
--  发布时间:2018/12/14 21:40:00
--  

表datacolchanged事件,有一列“流量”列,字符型,当输入一个无法转换为双精度小数型的字符时,提示并返回原值,我代码如下,可以弹出对话框却无法改回原值,哪里有问题?

If e.DataCol.name = “流量” Then
    If e.NewValue IsNot Nothing Then
        Dim n As String = e.NewValue
        Dim m As Double
        If Double.TryParse(n,m) = False Then
            MessageBox.show("无效格式!")
            e.DataRow(e.DataCol.Name) = e.OldValue
        End If
    End If
End If


--  作者:有点蓝
--  发布时间:2018/12/14 21:57:00
--  
放到datacolchanging事件

If e.DataCol.name = “流量” Then
    If e.NewValue IsNot Nothing Then
        Dim n As String = e.NewValue
        Dim m As Double
        If Double.TryParse(n,m) = False Then
 e.cancel = true
            MessageBox.show("无效格式!")
            
        End If
    End If
End If