请帮助我为IP地址写入数据窗口编辑掩码。目前我正在做这样的###.###.###.###,但它也可以允许300.300.300.300,并且有效的ip地址只允许最大255.255.255.255。请给我引路。谢谢
发布于 2015-05-13 19:06:47
你不能这么做。
您必须使用pbm_keydown或pbm_downkey作为事件id来创建一个用户事件,并编写一个脚本来阻止允许击键。返回值允许您拒绝或不拒绝该键。
发布于 2015-05-13 19:10:20
编辑掩码不会验证输入,它们只是格式化输入。最好使用itemchanged事件来验证数据。
发布于 2015-05-14 14:05:20
你的编辑掩码是可以的,如果我是你,我会在数据窗口中定义4个数字列,但是,如果你想要验证,你需要在itemchanged事件中编码:
ls_colname = dw_1.GetcolumnName()
Choose Case ls_colname
Case "subnet_msk_1"
if Integer(dw_1.getText()) > 255
MessageBox("Warning", "Incorrect Input, subnet mask value should not be > 255")
/*this will not let the datawindow accept the invalid input*/
return 1
end if
Case "subnet_msk_2"
/*do the same*/
Case "subnet_msk_3"
/*do the same*/
Case "subnet_msk_4"
/*do the same*/
/*write your logic here*/
End Choose如果您只想使用一个字符串cloumn,我相信您将需要使用mid()函数,只需在PB中按F1,您可以找到示例,在您的示例中:
ls_colname = dw_1.GetcolumnName()
Choose Case ls_colname
Case "subnet_msk"
if Mid(dw_1.getText(), 1, 4) > 255 OR Mid(dw_1.getText(), 4, 8) > 255 /*etc..*/
/*your logic here*/
end ifhttps://stackoverflow.com/questions/30206089
复制相似问题