By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,144 Members | 1,250 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,144 IT Pros & Developers. It's quick & easy.

Please explain

P: n/a
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.ExcludePromptAndLit erals

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
Apr 28 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a

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.ExcludePromptAndLit erals

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

Apr 28 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.