NET Framework 2.0ȍ~ł́AText Box Rg[̑Masked Text Box Rg[[email protected]܂B ႦMasked Text Box Rg[Maskvpe Bu99999vƂƁA5̐͂łȂȂ܂BMaskvpe B̏ɂẮAMSDŃu Masked Text Box. Validating Typevpe BgƁAMasked Text Box Rg[ɓ͂ꂽw肳ꂽ^ɕϊł邩̊m FARg[t H[JXɍsƂł܂BႦValidating Typevpe Bu Int32vɂƁARg[t H[JXA͂ꂽInt32. Mask will be composed from patterns and hardcoded chars.After a few minor customizations to the autogenerated code of “Longitude.cs” it should look like this: Now we implement the fields and properties.As this struct represents a latitude, you need three fields (degrees (°), minutes (‘) and seconds (“)).
Nevertheless this can be done in other parts in the code, namely the Parse function which I will cover later in this tutorial. Here it becomes apparent, that Masked Text Boxes are primarily made for strings of a fixed length. Though it is possible to use the mask symbol “9″ to denote an optional digit we will run into troubles when formatting a string with a minus sign at the first location (where we used the mask symbol “#”).Also we need a constructor that passes those three values. It is primarily used by the Form Design Manager to autogenerate code, which is not quite that useful to us as we wont be using this feature as we are creating our own, inherited class, but it can’t hurt to provide the mentioned functionality either.Also I will be using it (the in the Form Design Manager and choose “Set Mask …”). We are trying to represent a longitude which consists of a degree value between -180° and 180°, a minutes value between 0′ and 60′ and a seconds value between 0″ and 60″.Since most of the information I was able to find on the web was either discussing the former or problems implementing the latter, I decided to give it a go and share my findings.In a private project of mine I needed to provide some means of input for a latitude/longitude object.
I chose to include the Prompt character in the string as when we need to determine weather the entered longitude is valid we do have to check weather all numbers have been filled in.