Marco,
I think we have same idea how to do to simulate blur() method. When i
asked to forum, i though there are some Win API to do it. But, there are
not, right ?
Carolyne, I think your code is great also, but cause i need to simulate this
blur method for other object in form that have a tabindex value, so i must
assign code like yours in all similar object's lostfocus event, and i cant
set all my similar object with same name and give them an index no.
And i dont want to do it. Also, i think LostFocus event is just the event
that trigger when an object will lost their focus, but not to force that
object lost their focus, cmiiw, (this is what i want to do, so what Nigel's
solution is not match my criteria) But i appreciated your help thanks.
Unfortunately, vb doesnt give us chance to use inheritance facility, so we
cant set the blur method that we have created to be their (visual objects)
methods (just an idea :-))
thanks guy
Zulfazli
> -----Original Message-----
> From: Straforini, Marco [SMTP:marco.straforini@c...]
> Sent: Friday, July 26, 2002 12:00 AM
> To: professional vb
> Subject: [pro_vb] RE: What is VB similar method like blur() method in
> java script
>
> Maybe there are other ways to do it, this is what I wrote a while
> ago (trimmed a little a renamed it :-).
> Basically it loops through all controls until it finds the one
> with the next tab index. I put this code in a Timer loop just to
> check it and it works great.
> It does not check for TabStop property, probably it needs more testing
> and I never used it in production.
> If you want to put it in a bas module, pass Me as a parameter.
>
> Hope this help,
> Marco
>
> ----------------------------------------------------------
> Private Sub Blur()
> '' we need this because of late bounding
> On Error Resume Next
>
> Dim obj As Control
> Set obj = Me.ActiveControl
> If obj Is Nothing Then Exit Sub '' No active control
>
> Dim lTab As Long
> lTab = obj.TabIndex
> If Err.Number <> 0 Then Exit Sub '' no tab index
>
> Dim cTab As Long
> Dim minTab As Object
>
> For Each obj In Controls
> cTab = obj.TabIndex
> If Err.Number = 0 Then
> '' this control has the tab index
> If cTab = lTab + 1 Then
> obj.SetFocus '' found the right one
> Exit Sub '' I am out of here
> End If
> '' look for the control with the minimum tab index
> If minTab Is Nothing Then
> Set minTab = obj
> Else
> If cTab < minTab.TabIndex Then Set minTab = obj
> End If
> End If
> Err.Clear
> Next
>
> '' set the focus to the first control
> minTab.SetFocus
> End Sub
> -----------------------------------------------------
>
>
> ---
> Visual C# - A Guide for VB6 Developers
> This book will make it easy to transfer your skills
> from Visual Basic 6 to C#, the language of choice
> of the .NET Framework.
> http://www.wrox.com/ACON11.asp?ISBN=1861007175&p2p0059
>