|
-
Dec 14th, 2001, 09:33 AM
#1
Thread Starter
Junior Member
Text Box manipulation
I want to select all charaters previously typed into a text box (as if you double click inside the box) so the next key stroke overwirtes what was there.
How?
While you are at it, how to make sucessive presses of the left arrow key erase the last character in a text box and leave the cursor there.
-
Dec 14th, 2001, 09:36 AM
#2
-= B u g S l a y e r =-
VB Code:
Private Sub Command1_Click()
Text1.SetFocus
Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
End Sub
-
Dec 14th, 2001, 09:39 AM
#3
-= B u g S l a y e r =-
VB Code:
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyLeft Then
KeyCode = 0
SendKeys "{BACKSPACE}"
End If
End Sub
-
Dec 14th, 2001, 10:30 AM
#4
Frenzied Member
I have made a DLL that does all that for you. You can grab it and use it for free. It does tons more as well.
CommonCode DLL
~Peter

-
Dec 14th, 2001, 10:36 AM
#5
Conquistador
but he only wants to do 2 things, which he has achieved.
why add a dll if you can do it in 5 lines of code?
-
Dec 14th, 2001, 10:40 AM
#6
Frenzied Member
Excellent point.
The answer is he could probably find many of the other features of the DLL useful. And since it is a free DLL, and he is more than welcome to distribute it freely without royalty or credit to me, the chance that it will become a useful tool in building his app are greater.
Did you look at the list of things it does? The name CommonCode says it all.
(and yes, i did generate some of the code in there with the help you all the great folks on this forum. i'm just happy i can share it with you all)
~Peter

-
Dec 14th, 2001, 11:04 AM
#7
Thread Starter
Junior Member
I just ended a class in Visual Basic, just scratched the surface of what can be done.
Concerning the DLL, if I only knew what a dll is and how to use it...
I suppose in time I will learn.
-
Dec 14th, 2001, 11:07 AM
#8
Frenzied Member
Hahhaa.
Don't worry KMMATH, i provide a complete sample application with the DLL so you can easily just look at the code.
Failing that, you can always ask me or the folks here in this forum.
~Peter

-
Dec 14th, 2001, 07:52 PM
#9
Conquistador
hmmm
not bad
is it "open" soruce?
i wouldn't mind seeing how u handle the restriction of entry into a text box....
like, how you apply it to a textbox
-
Dec 16th, 2001, 06:36 PM
#10
Frenzied Member
No. Sorry da_silvy. It's not an open source DLL.
BUT - none of the code in there is top secret. It's all simple code i have learned over the last few years, as well as a few special functions that i had help with from people here in this forum.
Like i said .... it's a free DLL. There is no charge for it, and no need to give me credit if you use it in a project. I just got sick of always adding the same code into every new project, so i decided to make it simplier by packaging all those functions into a single file.
~Peter

-
Dec 21st, 2001, 02:49 AM
#11
Conquistador
hehehe
i didn't ask if it was open source, i just asked if i could see it 
That's fine. i just wanted to see how u would set the format of the textbox from an external dll...
-
Dec 21st, 2001, 12:14 PM
#12
Frenzied Member
Well, .... in YOUR program, you would have this code:
VB Code:
Private Sub txtHighlight_GotFocus()
Call CC.HighlightEntireSelection(txtHighlight)
End Sub
That is done quite simply in my DLL by doing this:
VB Code:
Public Sub HighlightEntireSelection(ByRef objTextArea As Object)
'Highlights the entire selection
On Error Resume Next
If TypeOf objTextArea Is ComboBox Or TypeOf objTextArea Is TextBox Then
objTextArea.SelStart = 0
objTextArea.SelLength = Len(objTextArea.Text)
End If
End Sub
See. Nothing special. Just code that well all understand. I just packaged it all up into a really easy to use DLL. It's made all my projects smaller.
~Peter

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
|