Senin, 29 Oktober 2012

[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>
> 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
> >
>

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