0

few years ago I was made a project on vb net It was a code to validate if the value was zip code for United States or postal code for Canada. I want to do same thing with c#.

Private Sub txtCodePostal_KeyDown(sender As Object, e As KeyEventArgs) Handle txtCodePostal.KeyDown
   IsNumeric(Me.txtPostalCode.Text) Then

Convert vb net code in c#

  • 1
    Is [C#- Validation for US or Canadian zip code](https://stackoverflow.com/questions/14942602/c-validation-for-us-or-canadian-zip-code) of any use to you? – Andrew Morton Mar 24 '22 at 12:48
  • @AndrewMorton it's good for validating the format, but doesn't ensure that it's still a valid postal/zip code for either country. OP it would be best to reach through an API to confirm this if possible. – Trevor Mar 24 '22 at 14:11
  • 1
    @Trevor Agreed; I linked to it because it appeared to offer a zero-cost improvement over IsNumeric. – Andrew Morton Mar 24 '22 at 15:00
  • We have the [Zip-4](https://en.wikipedia.org/wiki/ZIP_Code#ZIP+4) in the US, in the format 00000-0000, which !IsNumeric – djv Mar 24 '22 at 15:19

0 Answers0