Senin, 29 Oktober 2012

RE: [ExcelVBA] Re: XL2007 Unable to select Form TextBox with code

 

I don't have a bad-value test ... I simply call the message box (and do
the other things) every time.

"Call" is the VBA keyword for calling a sub or built-in sub.

It is not required, but I use it because it allows the parameters to be
put inside parentheses in the same way that they are for a function
call. My opinion is that it makes the code more readable in the long
run.

I had the MsgBox inside the With because I included the .Text from the
textbox in its parameters.

> I understand the With TextBox and its components ...

A With doesn't have components, it simply makes the components of the
TextBox available without needing to constantly repeat TextBox in all
the enclosed statements.

Regards, Dave S

________________________________

From: ExcelVBA@yahoogroups.com [mailto:ExcelVBA@yahoogroups.com] On
Behalf Of noskosteve
Sent: Tuesday, 30 October 2012 12:42
To: ExcelVBA@yahoogroups.com
Subject: [ExcelVBA] Re: XL2007 Unable to select Form TextBox with code

Looks like I'm not quite finished.
I am puzzled by the Call *inside* the With.

I understand the With TextBox and its components (.SelStart &
SelLength), but a Call inside I can not understand.

My brain thinks that after the bad value test I pop up the message,
*THEN* do the TextBox stuff...

(periods added for Yahoo formatting help, I hope)

.If ValueBad then
. MsgBox "You goofed...Bla...Bla" ' I omit the "Call".
. With TextBox
. .SelStart = 0
. .SelLength = Len(.Text)
. End With
. Cancel.Value = True
.EndIf
.......

Izat' the same thing?

Regards, Steve

--- "David Smart" wrote:
>
>
> Option Explicit
>
> Private Sub TextBox1_BeforeUpdate(ByVal Cancel As
MSForms.ReturnBoolean)
> With TextBox1
> Call MsgBox("Rejecting " & .Text)
> .SelStart = 0
> .SelLength = Len(.Text)
> End With
> Cancel.Value = True
> End Sub
>
> Regards, Dave S
>
> ----- Original Message -----
> From: "noskosteve" <noskosteve@...>
> To: <ExcelVBA@yahoogroups.com <mailto:ExcelVBA%40yahoogroups.com> >
> Sent: Monday, October 29, 2012 4:02 PM
> Subject: [ExcelVBA] Re: XL2007 Unable to select Form TextBox with code
>
>
> >
> >
> >> One I like is the EnterFieldBehavior property, ...
> >
> > This is set already to SelectAll. Tabbing into the TextBox has the
entire
> > contents selected as I want, but not so with the Cancel.Value
thingy.
> >
> >
> >> There also seem to be SelStart and SelLength properties...
> > I have been unable to get these to do what I Help seems to be
saying.
> > SelStart = 0 (set cursor to beginning) and SelLength = 3 (select 3
> > characters) aren't doing what the help is saying, but instead, the
next
> > Form Control in the Tab order gets selected instead of the current
> > TextBox...Arrrrg!
> >
> > Something else perhaps like some condition must not be correct. Some

> > fiddling is in order.
> >
> > Thanks, Steve N.
> >
> >
> >
> > ------------------------------------
> >
> > ----------------------------------
> > 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
> >
> > ----------------------------------Yahoo! Groups Links
> >
> >
> >
> >
> >
> > -----
> > No virus found in this message.
> > Checked by AVG - www.avg.com
> > Version: 10.0.1427 / Virus Database: 2441/5359 - Release Date:
10/28/12
> >
>

----------

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]

__._,_.___
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (9)
Recent Activity:
----------------------------------
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