Find Code:
All Words
Any of the Words
Exact Phrase
Home
:
Code
:
Forums
:
Submit
:
Mailing List
:
About
:
Contact
Code
All
VB.NET
ASP.NET
C#
VB Classic
ASP Classic
Snippets
Popular
Resources
Submit Code
Forums
Articles
Tips
Links
Books
Contest
Link to us
Allows you to quickly select an entire line of tex...
Author:
SirCodezAlot
E-mail:
Click to e-mail author
Submitted:
8/22/2002
Version:
VB5
Compatibility:
VB5, VB6
Category:
Controls
Views:
8598
Allows you to quickly select an entire line of text from a normal VB textbox.
Declarations:
'none
Code:
Public Sub SelectLine(txtControl As TextBox, ByVal theLine As Integer) Dim lneCount As Integer 'Number of lines found Dim lneTxt As String 'Text of current line lneCount = 0 For a = 1 To Len(txtControl.Text) 'Add next character of line lneTxt = lneTxt & Mid(txtControl.Text, a, 1) 'If the next two characters are end-of-line markers If Mid(txtControl.Text, a, 2) = vbCrLf Then 'Increase line count lneCount = lneCount + 1 'If the current line is the line to be selected If lneCount = theLine Then 'Select the line and exit the sub txtControl.SelStart = (a - 1) - Len(lneTxt) txtControl.SelLength = Len(lneTxt) Exit Sub Else 'Skip to the next line and empty the text holder a = a + 1 lneTxt = "" End If 'If the end of the text has been reached ElseIf a = Len(txtControl.Text) Then lneCount = lneCount + 1 If lneCount = theLine Then txtControl.SelStart = a - Len(lneTxt) txtControl.SelLength = Len(lneTxt) Exit Sub End If End If Next a End Sub
Home
|
Forums
|
Submit
|
Books
|
Mailing List
|
Advertising
|
About
|
Contact
© 2024 A1VBCode. All rights reserved.
Legal disclaimer & terms of use
Privacy statement