Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > Highlighting textboxes?


Reply
 
Thread Tools Display Modes
  #1  
Old 10-26-2005, 11:59 AM
kpearson kpearson is offline
Centurion
 
Join Date: Feb 2005
Location: North Carolina
Posts: 146
Default Highlighting textboxes?


I am trying to highlight my textboxes, but this peice of code doesn't do it. I have searched posts for similar code and they look very similiar. I tried different ones, but nothing works. Can someone look at this and tell me what is wrong with it?
Thanks
Code:
Public Sub Highlight()
With Screen.ActiveForm
    If (TypeOf .ActiveControl Is TextBox) Then
        .ActiveControl.SelStart = 0     'SelStart specifies the starting position
        .ActiveControl.SelStart = Len(.ActiveControl)
    End If
End With
End Sub
Private Sub Text1_GotFocus(Index As Integer)
    Highlight
End Sub
there are 4 textboxes in a control array.
Reply With Quote
  #2  
Old 10-26-2005, 12:05 PM
LaVolpe's Avatar
LaVolpe LaVolpe is offline
Ultimate Contributor

* Expert *
 
Join Date: Apr 2004
Location: Illinois
Posts: 2,499
Default

You are setting .SelStart twice, the 2nd one should be .SelLength, no?
__________________
Insomnia is a simple byproduct of "it can't be done" {Window Shaper}
Reply With Quote
  #3  
Old 10-26-2005, 12:13 PM
Diurnal Diurnal is offline
Enthusiast

Retired Leader
* Expert *
 
Join Date: Apr 2002
Location: Bellevue, WA.
Posts: 3,233
Default

Additionaly to the .SelStart issue, there can only be one active control so that only one will be highlighted, probably the first in the tab order.
Reply With Quote
  #4  
Old 10-26-2005, 12:20 PM
kpearson kpearson is offline
Centurion
 
Join Date: Feb 2005
Location: North Carolina
Posts: 146
Default

Thanks a bunch. I don't know how that didn't puzzle me to begin with, but maybe I have stared at it too long.
Thanks again
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->