Home All Groups Group Topic Archive Search About
Author
28 Apr 2006 2:31 PM
John
I am having trouble understanding how to use different properties.  For
example, I have a maskedtext box on a form.  Lets call it msk1.  I want to
remove the mask from  msk1.  I figured out to do the following:
msk1.textMaskFormat=maskFormat.ExcludePromptAndLiterals

However, I don't understand why the following doesn't work.
msk1.textMaskFormat.ExcludePromptAndLiterals

To put it simply, I am having trouble understanding how to use a lot of the
properties or methods.

Could somebody please explain or give me a link to documentation that
explains what I am asking?  Please don't say buy a book.  I have looked at
different books, but obviously not clueing into this information.  Therefore,
I wouldn't know exactly what to read again.

Thank you

Author
28 Apr 2006 3:09 PM
Larry Lard
John wrote:
> I am having trouble understanding how to use different properties.  For
> example, I have a maskedtext box on a form.  Lets call it msk1.  I want to
> remove the mask from  msk1.  I figured out to do the following:
> msk1.textMaskFormat=maskFormat.ExcludePromptAndLiterals
>
> However, I don't understand why the following doesn't work.
> msk1.textMaskFormat.ExcludePromptAndLiterals
>
> To put it simply, I am having trouble understanding how to use a lot of the
> properties or methods.

First place to start is the docs. The docs for the textMaskFormat
property of a MaskedTextBox say:

Public Property TextMaskFormat As MaskFormat

So we see that TextMaskFormat is a property that has a value of type
MaskFormat. Following the link we see that MaskFormat is an Enum that
has various values. Assuming you have a correct conceptual
understanding of what properties and enums are, it's hard to know what
to say next. We have a property; we want to change the value of that
property; so we use an assignment statement to set the value of the
property to the value we want it to have.

Maybe it would help to think of Enums as 'magic numbers with names' ?
As it happens MaskFormat.ExcludePromptAndLiterals 'is' just the number
zero, with a special name. If we didn't have this Enum available, we
would have to do something like

msk1.TextMaskFormat = 0

in which presumably its more obvious what's happening? We are urged to
avoid magic numbers in our code, and predefined Enums are in this
situation just a way of enforcing that.


--
Larry Lard
Replies to group please