Dear All
Surely, David should have said :-
>With Mem_FirstMM
> .SelStart = 0
> .SelLength = Len(.Text)
>End With
>is the same as simply saying
>Mem_FirstMM.SelStart = 0
>Mem_FirstMM.SelLength = Len(Mem_FirstMM.Text) ' [not Len(.Text)]
For me the issue here is readability (simplicity even) and this is why the With . . End With wins out.
I am a great fan of With . . End With but detractors claim it can produce unreadable code. Well maybe they do ?
And Steve, still talking readability,
what is Mem_FirstMM ?
Regards
Derek Turner
+++
>________________________________
> From: "david.smart@ubs.com" <david.smart@ubs.com>
>To: ExcelVBA@yahoogroups.com
>Sent: Tuesday, 30 October 2012, 5:05
>Subject: RE: [ExcelVBA] Re: XL2007 Unable to select Form TextBox with code
>
>
>
>Re "With" not having components ...
>
>I suppose what I'm getting at is that it's important not to think of
>With as a component in its own right. It's just a shorthand way of
>writing code. E.g.
>
>With Mem_FirstMM
>.SelStart = 0
>.SelLength = Len(.Text)
>End With
>
>is the same as simply saying
>
>Mem_FirstMM.SelStart = 0
>Mem_FirstMM.SelLength = Len(.Text)
>
>So, it's important to remember that it's the Mem_FirstMM components you
>are accessing.
>
>This becomes more relevant when you have complicated With constructs
>(either nested or comma separated in the one With) and you have to keep
>track of which objects the With is providing you shorthand access to.
>
>Some people hate With and won't use it. Certainly, code with nested or
>comma-separated With items can very quickly become unreadable.
>
>Regards, Dave S
>
>
>________________________________
>
>From: ExcelVBA@yahoogroups.com [mailto:ExcelVBA@yahoogroups.com] On
>Behalf Of noskosteve
>Sent: Tuesday, 30 October 2012 13:49
>To: ExcelVBA@yahoogroups.com
>Subject: [ExcelVBA] Re: XL2007 Unable to select Form TextBox with code
>
>Couldn't wait. My method works fine...
>
>> I don't have a bad-value test ...
>I understood your example 100% & wasn't question it, sorry.
>
>> "Call" is ... not required... parameters ... inside parentheses
>I know this. I Shouldn't have mentioned it. I just don't usually include
>it for Msg boxes.
>
>> I had the MsgBox inside the With because I included
>> the .Text from the textbox in its parameters.
>Ahhh! Some of this does make sense, Steve. I sez to self. I'll keep that
>trick in mind.
>
>> > I understand the With TextBox and its components ...
>> A With doesn't have components, it simply makes the
>> components of the TextBox available ...
>
>Ah well. A Rose is a Flower. I picked that term not knowing if there was
>better jargon figuring you'd know what I meant, but I still think it
>flys ok. They could be considered components of the With as well, no?
>... parameters...operands... arguments, even (for argument sake...so to
>speak)(;-)
>
>Here's my functioning snippet - cool to see text now selected. (I also
>played with some of the things to help understand the function of each -
>especially the Cancel.Value)
>
>. If Mem_FirstMM < 1 Then
>. MsgBox "The First memory can not be < 1 ..." ' detail omitted
>. With Mem_FirstMM
>. .SelStart = 0 ' Cusor at left
>. .SelLength = Len(.Text) ' Nice touch. Select it all
>. End With
>. Cancel.Value = True ' kill User goof.
>. End If
>
>Thanks, Steve N.
>... Still playing ...
>
>----------
>
>Visit our website at http://www.ubs.com
>
>This message contains confidential information and is intended only
>for the individual named. If you are not the named addressee you
>should not disseminate, distribute or copy this e-mail. Please
>notify the sender immediately by e-mail if you have received this
>e-mail by mistake and delete this e-mail from your system.
>
>E-mails are not encrypted and cannot be guaranteed to be secure or
>error-free as information could be intercepted, corrupted, lost,
>destroyed, arrive late or incomplete, or contain viruses. The sender
>therefore does not accept liability for any errors or omissions in the
>contents of this message which arise as a result of e-mail transmission.
>If verification is required please request a hard-copy version. This
>message is provided for informational purposes and should not be
>construed as a solicitation or offer to buy or sell any securities
>or related financial instruments.
>
>UBS reserves the right to retain all messages. Messages are protected
>and accessed only in legally justified cases.
>
>[Non-text portions of this message have been removed]
>
>
>
>
>
[Non-text portions of this message have been removed]
Reply via web post | Reply to sender | Reply to group | Start a New Topic | Messages in this topic (13) |
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.
----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA
----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com
----------------------------------
Tidak ada komentar:
Posting Komentar