|
-
Jan 11th, 2002, 06:02 PM
#1
Thread Starter
New Member
textbox selstart
Hey,
I've written a subroutine to disable pasting in a textbox, by checking whats just gone into the textbox against what's in the clipboard...
Private sub txtSuppSurn_Change()
Call disablepaste(txtSuppSurn)
End Sub
And in a module
Public Sub disablepaste(box As textbox)
Dim position As Integer
position = box.SelStart
If box.SelStart - Len(Clipboard.GetText) >= 0 Then
box.SelStart = box.SelStart - Len(Clipboard.GetText)
box.SelLength = Len(Clipboard.GetText)
If box.SelText = Clipboard.GetText Then box.SelText = "" Else box.SelStart = position
box.SetFocus
End If
End Sub
Fine, works grand, but i've got a small bonus feature (error) like this: if the lenght of the textbox is above about 8,9 or 10 chars, it looks like the start of the string is chopped off.
It isn't, the textbox has scrolled along... since this is all supposed to be invisible, that's not good... any ideas? I'd like to keep the processing more or less the same way, so i can selectively disable the pasting etc...
Cheers
Des
-
Jan 11th, 2002, 08:18 PM
#2
Need-a-life Member
I don't know... but try this:
VB Code:
Option Explicit
Private Sub txtSuppSurn_Change()
DisablePaste txtSuppSurn
End Sub
Public Sub DisablePaste(box As TextBox)
Dim Position As Integer
Position = box.SelStart
If box.SelStart - Len(Clipboard.GetText) >= 0 Then
box.SelStart = box.SelStart - Len(Clipboard.GetText)
box.SelLength = Len(Clipboard.GetText)
If box.SelText = Clipboard.GetText Then
If Len(box.Text) > Len(box.Tag) + 1 Then
box.SelText = ""
Else
box.SelStart = Len(box.Text)
End If
Else
box.SelStart = Position
End If
box.SetFocus
box.Tag = box.Text
End If
End Sub
Emiliano F. Martín
If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
Encourage the person who helped you to keep doing it, and give him the points he deserves.
MP3 Organizer: Freeware to logically organize all your MP3s.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|