我一直在寻找实现此目的的方法,但是我发现它很困难:(
I have been searching around for a way to do this but I am finding it hard :(
我对VBA非常陌生(实际上,我还没有使用过它),但我下定了决心!
I am very very very new to VBA (In fact, I have not used it) but I am determined !
我想做的是验证邮政编码,以便对其进行格式化并检查.我已经尝试了输入掩码和验证,但这并不完美.所以我转向了VBA.
What I want to do is validate a postcode so that it formats it and checks it. I have tried Input mask and validation, but this are not perfect. So I have turned to VBA.
我找到了代码示例,并将其放入VBA中,但我无能为力:(
I have found examples of code, and put them into VBA, but I can't get it to do anything :(
它需要使用这些邮政编码...
It needs to work with these postcodes ...
A9 9AA
A9A 9AA
A99 9AA
AA9 9AA
AA9A 9AA
AA99 9AA
如果有人可以帮助,那就太好了.但是如果有人可以给我一个包含验证器的数据库,那将是最好的,这样我就可以在实践中看到它并学习.但是任何事情都会好.只是如何使它工作将是一件好事:).我要做的是将代码此处粘贴并粘贴到模块中,希望最好,但是什么也没发生?
If anyone could help it would be great. But what would be best if someone could give me a database with the validator in, so I could see it in action and learn. But anything would be good. Just how to make it work would be good :) . What I have done is copy and pasted the code Here into a module and hoped for the best, but nothing happened ?
所以任何帮助都会很好.
So any help would be good.
谢谢
推荐答案您可以使用将所有英国邮政编码下载到数据库的建议.但是,随着以后添加新代码,您将不得不紧随其后.我敢肯定有一个自动的免费服务可以为您做到这一点,但这对您来说是非常高级的编程.
You can use the suggestion of downloading all the UK Post Codes to your database. However, you'll have to stay on top of it as new codes are added later. I'm sure there's an automatic free service out there that will do this for you, but that would be very advanced programming for you.
如果您只想验证模式,我发现 此示例 .它不仅可以验证模式,还可以纠正常见的拼写错误.
If you want to just validate the pattern, I found this example. It will not only validate the pattern, but also correct for common typo errors.
如果您确实使用此代码,则仍必须在正确的时间调用它.可能是因为用户在输入代码后离开了文本框,或者是他们试图保存记录或移至另一条记录(自动保存).
If you do use this code, you'll still have to call it at the correct time. That could be when the user leaves the textbox after entering the code, or when they are trying to save the record, or move to another record (automatic save).
祝你好运
更多推荐
验证Access中的邮政编码?
发布评论