| Author |
Highlightng Text from anywhere
|
|
| David Bland 2005-11-25, 6:55 pm |
| Hi
What I want to do is to be able to pass a text box name from anywhere and
highlight the text. I thought this would work, but it does not.
HighlightText txtTextBox.Name
Private Sub HighlightText(txtBoxIn As TextBox)
With txtBoxIn
.SelStart = 0
.SelLength = Len(txtBoxIn.Text)
End With
End Sub
I get a Type Mismatch on the .Name any ideas?
| |
| Rick Rothstein [MVP - Visual Basic] 2005-11-25, 6:55 pm |
| > What I want to do is to be able to pass a text box name from
anywhere and
> highlight the text. I thought this would work, but it does not.
>
> HighlightText txtTextBox.Name
>
> Private Sub HighlightText(txtBoxIn As TextBox)
> With txtBoxIn
> .SelStart = 0
> .SelLength = Len(txtBoxIn.Text)
> End With
> End Sub
>
> I get a Type Mismatch on the .Name any ideas?
The Name of a control is a String... your function is expecting the
control itself. Use this to call the function (it passes the control
itself into the function)...
HighlightText txtTextBox
Rick
| |
|
| Remove .Name
txtTextBox alone should do it
"David Bland" <DavidBland@discussions.microsoft.com> wrote in message
news:65753CE4-9308-42E7-955C-536B9D054F51@microsoft.com...
> Hi
>
> What I want to do is to be able to pass a text box name from anywhere and
> highlight the text. I thought this would work, but it does not.
>
> HighlightText txtTextBox.Name
>
> Private Sub HighlightText(txtBoxIn As TextBox)
> With txtBoxIn
> .SelStart = 0
> .SelLength = Len(txtBoxIn.Text)
> End With
> End Sub
>
> I get a Type Mismatch on the .Name any ideas?
|
|
|
|