如何在四个字符组中编辑IBAN号? [英] How to edit an IBAN number in four character groups?

查看:169
本文介绍了如何在四个字符组中编辑IBAN号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

https://en.wikipedia.org/wiki/International_Bank_Account_Number#Practicalities

以电子方式发送时,IBAN不应包含空格: 打印时,以四个字符为一组,用四个字符隔开 单个空格,最后一组长度可变,如图所示 下面的示例:

典型的IBAN如下所示:GR16 0110 1250 0000 0001 2300 695(来自上面的链接).

我想让用户更容易输入IBAN编号.当前,我使用TDBEdit来显示IBAN编号,并将其作为字符(不带空格)存储在数据库中.

我知道可以使用TNumericField.DisplayFormat格式化数字,也有TMaskEdit,但是两者对于这个目的并不是很有用,因为IBAN不是数字,并且在不同国家/地区具有不同的长度.

如何在DB控件中的四个字符组中编辑IBAN号?

PS:我并没有要求进行实际的IBAN验证,因为我已经知道了.

解决方案

您可以使用IBAN字段的EditMask属性,因为这也适用于字符串字段.适用于IBAN的EditMask可能如下所示:

">LL00 aaaa aaaa aaaa aaaa aaaa aaaa aaaa aa;0; "

第一个字符使编辑字段将所有字符都转换为大写.接下来的四个条目需要两个字母字符,然后是两个数字字符.空白代表要求的差距.较低的"a"允许使用字母数字字符,但不需要.

掩码第二部分中的"0"将从字段中存储的条目中删除所有文字(空格空白).

遮罩第三部分中的空白使间隙空白显示为空白.

https://en.wikipedia.org/wiki/International_Bank_Account_Number#Practicalities

The IBAN should not contain spaces when transmitted electronically: when printed it is expressed in groups of four characters separated by a single space, the last group being of variable length as shown in the example below:

A typical IBAN looks like this: GR16 0110 1250 0000 0001 2300 695 (taken from the above link).

I want to make it easier for users to enter IBAN numbers. Currently I use a TDBEdit to display the IBAN number and it is stored as characters (without the spaces) in the database.

I know that it is possible to format numbers using TNumericField.DisplayFormat, also there is TMaskEdit, but both aren't terribly useful for this purpose as IBAN is not a number and has different lenghts in different countries.

How to edit an IBAN number in four character groups in a DB control?

PS: I'm not asking for the actual IBAN validation as I already have that figured out.

解决方案

You can use the EditMask property of the IBAN field as this will also work for string fields. A suitable EditMask for IBAN may look like this:

">LL00 aaaa aaaa aaaa aaaa aaaa aaaa aaaa aa;0; "

The first character makes the edit field convert all characters to upper case. The next four entries require two alpha characters followed by two numeric ones. The blanks represent the requested gaps. The lower "a" allows an alphanumeric character but doesn't require it.

The "0" in the second part of the mask will strip any literals (the gap blanks) from the entry stored in the field.

The blank in the third part of the mask makes the gap blanks being displayed as blank.

这篇关于如何在四个字符组中编辑IBAN号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆