You have to THINK anyway, so why not think BIG?
- Donald Trump
News
Site News
Latest Comments
Affiliates
Proxies
Contribute!
Chat
Tutorials
Newest Articles
Most Popular
Highest Rated
Latest Comments
Code Samples
Newest Code
Most Popular
Highest Rated
Latest Comments
Blogs
Admins Blog
Newest Blogs
Most Popular
Highest Rated
Latest Comments
Forums
Latest Posts
Latest Topics
Memberlist
[login]
|
[Register]
Text Editor
by: bs0d
Description:
This text editor is by no means complete, just an example for searching within the editor, cut, copy and pasting text as well. All of the options are in the menu of the program.
See Full Size
Code:
Private Sub Form_Resize() txtEdit.Height = frmEdit.ScaleHeight txtEdit.Width = frmEdit.ScaleWidth End Sub Private Sub mnuEdit_Click() If txtEdit.SelText = "" Then mnuEditCut.Enabled = False mnuEditCopy.Enabled = False Else mnuEditCut.Enabled = True mnuEditCopy.Enabled = True End If If Clipboard.GetText() = "" Then mnuEditPaste.Enabled = False Else mnuEditPaste.Enabled = True End If End Sub Private Sub mnuEditCopy_Click() Clipboard.Clear 'clear clipboard Clipboard.SetText txtEdit.SelText 'send text to clipboard End Sub Private Sub mnuEditCut_Click() Clipboard.Clear 'clear clipboard Clipboard.SetText txtEdit.SelText 'send text to clipboard txtEdit.SelText = "" 'remove selected text from text box End Sub Private Sub mnuEditFind_Click() Const conBtns As Integer = vbOKOnly + vbInformation _ + vbDefaultButton1 + vbApplicationModal Const conMsg As String = "The search string was not found." Dim intRetVal As Integer Dim intFoundPos As Integer strSearchFor = InputBox("Find what?", "Find") intFoundPos = InStr(1, txtEdit.Text, strSearchFor, 1) If intFoundPos = 0 Then intRetVal = MsgBox(conMsg, conBtns, "Find") Else txtEdit.SelStart = intFoundPos - 1 txtEdit.SelLength = Len(strSearchFor) End If End Sub Private Sub mnuEditFindNext_Click() Const conBtns As Integer = vbOKOnly + vbInformation _ + vbDefaultButton1 + vbApplicationModal Const conMsg As String = "The search has been completed." Dim intRetVal As Integer Dim intFoundPos As Integer, intBegSearch As Integer intBegSearch = txtEdit.SelStart + 2 intFoundPos = InStr(intBegSearch, txtEdit.Text, strSearchFor, 1) If intFoundPos = 0 Then intRetVal = MsgBox(conMsg, conBtns, "Find Next") Else txtEdit.SelStart = intFoundPos - 1 txtEdit.SelLength = Len(strSearchFor) End If End Sub Private Sub mnuEditPaste_Click() 'Retrieve text from clipboard, paste into textbox txtEdit.SelText = Clipboard.GetText() End Sub Private Sub mnuFileExit_Click() Unload frmEdit End Sub
No Comments for this page.
You Must be
signed in
or a
member
to comment.
Code Stats
14,577
Views
0
Total Comments
0
Rating of 5 (
Votes)
Code Options
·
Login to Rate This Code
·
Login to Post a Comment
·
Read more by this author
Related
·
RGB Color Fader
·
Adder
·
Math Problems
·
Cut and Paste
·
Combo Box Colors
·
Flag Viewer
"AllSyntax.com" Copyright © 2002-2021; All rights lefted, all lefts righted.
Privacy Policy