Please explain

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
John said:
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.
 
Anybody find Larry Lard's answer somewhat over the top? John was simply asking how to format a masked text box... I wonder if Larry is an A-Hole that tries to confuse beginners....

here is the right answer for anybody else looking for it:
'(my mask text box is named mskTxtBox)

mskTxtBox.TextMaskFormat = MaskFormat.ExcludePromptAndLiterals

From http://www.developmentnow.com/g/38_2006_4_0_0_746135/Please-explain.htm

Posted via DevelopmentNow.com Groups
http://www.developmentnow.com/g/

No, I didn't find the reply over the top.

The solution you are stating here is exactly what John (the original
poster) said that he found worked for his situation. The question was
on the best way to find the correct documentation for the class and how
to accomplish what he wanted. Larry's answer to that question was
reasonable.
 
Back
Top