Results 1 to 29 of 29

Thread: VB6 - Text Editor

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2012
    Posts
    1,476

    VB6 - Text Editor

    I found a need for addtional functions that NotePad did not provide, so I came up with my own Text Editor. It has most of the functions of NotePad with a couple of extra ones.
    Code:
    File		Edit		Format		Search
    -New		-Undo		-Word Wrap	-Find
    -Open		-Cut		-Sort		-Find Next
    -Save		-Copy		-Font
    -Save as	-Paste
    -Print		-Delete
    -Exit		-Replace
                    -Select All
    The noticeable extra is the Sort function, which is covered in a previous post. The other extra is the ability to replace character ranges per line in addition to search and replace specific text. This is accomplished by replacing the double characters CrLf with a single character Cr, using a Split function to separate individual lines into a string array, looping through each line to replace the selected character range, and reassembling the complete string with the Join function. For large text files, search and Replace All by text will be slow, whereas Replace All by character count will be fast by comparison.

    The print function has taken some time to put together, as printing from a Text Box is not straight forward, and it has experienced limited testing due to lack of an available printer. It also has been covered in a previous post.

    The Line/Col function that comes with Text Editor is not considered an option, as in NotePad. Unlike NotePad, it is available in either Wrap or Unwrap modes, and is only activated by mouse click. If it is important to you, you are welcome to add activation by cursor keys.

    Originally I used the API to perform the Edit functions since the VB functions were limited to 64K. But then I discovered that the keyboard functions are not limited to 64K, and perform most of those tasks quite well and with good speed. So it made a lot of sense to use the keyboard functions instead.

    Like NotePad, Text Editor provides an adjustable window that remembers it's location and size.

    The surprising part of this effort is that with the additional functionality provided, the executable is 1/3 the size of Notepad. I have added functions that meet my current needs, and other users may have specific functions that can be added to meet their needs.

    J.A. Coutts
    Attached Images Attached Images   
    Attached Files Attached Files

  2. #2
    PowerPoster
    Join Date
    Sep 2012
    Posts
    2,083

    Re: VB6 - Text Editor

    Very useful tool, thank you, couttsj.

  3. #3
    Frenzied Member
    Join Date
    Dec 2008
    Location
    Melbourne Australia
    Posts
    1,487

    Re: VB6 - Text Editor

    Thanks for sharing.
    I like the Sort ability.
    I like to minimize dependencies. Could it work without the FSO ?

    Rob

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2012
    Posts
    1,476

    Re: VB6 - Text Editor

    Quote Originally Posted by Bobbles View Post
    Thanks for sharing.
    I like the Sort ability.
    I like to minimize dependencies. Could it work without the FSO ?

    Rob
    Sorry for the delay in responding, but we have moved and are not connected to the Internet yet (using the neighbor's WiFi currently).

    Yes, of course it can be done, and most of the time I do not use the FSO. This program was developed from a much simpler version that used the FSO. If you can wait until my development machine is back online, I can post a non-FSO version, or you can check one of my other posts that contains an OpenFile sub routine.

    J.A. Coutts

  5. #5
    Frenzied Member
    Join Date
    Dec 2008
    Location
    Melbourne Australia
    Posts
    1,487

    Re: VB6 - Text Editor

    Quote Originally Posted by couttsj View Post
    Sorry for the delay in responding, but we have moved and are not connected to the Internet yet (using the neighbor's WiFi currently).

    Yes, of course it can be done, and most of the time I do not use the FSO. This program was developed from a much simpler version that used the FSO. If you can wait until my development machine is back online, I can post a non-FSO version, or you can check one of my other posts that contains an OpenFile sub routine.

    J.A. Coutts
    Thanks, that would be great,
    Rob

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2012
    Posts
    1,476

    Re: VB6 - Text Editor

    Rob;
    Here is a version of TextEditor that does not use the FSO. It was a fairly straight forward conversion using my OpenFile routine and the Get/Put functions. Please let me know if you find any bugs/errors as it has undergone little testing.

    J.A. Coutts

    Updated: 06/15/2018
    Attached Files Attached Files
    Last edited by couttsj; Jun 15th, 2018 at 10:51 PM.

  7. #7
    Fanatic Member
    Join Date
    Aug 2016
    Posts
    678

    Re: VB6 - Text Editor

    Quote Originally Posted by couttsj View Post
    Rob;
    Here is a version of TextEditor that does not use the FSO. It was a fairly straight forward conversion using my OpenFile routine and the Get/Put functions. Please let me know if you find any bugs/errors as it has undergone little testing.

    J.A. Coutts
    may be

    Call Shell(Environ("COMSPEC") & " /c type " & """" & m_Filename & SortCmd & """", vbHide)

    replace

    Call Shell(Environ("COMSPEC") & " /c type " & m_Filename & SortCmd, vbHide)

  8. #8

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2012
    Posts
    1,476

    Re: VB6 - Text Editor

    Quote Originally Posted by xxdoc123 View Post
    may be

    Call Shell(Environ("COMSPEC") & " /c type " & """" & m_Filename & SortCmd & """", vbHide)

    replace

    Call Shell(Environ("COMSPEC") & " /c type " & m_Filename & SortCmd, vbHide)
    Why would you find it necessary to double quote something that is already string data?

    C:\Windows\system32\cmd.exe /c type C:\VB98\Utility\TxtEdit\logfile.txt|sort /+25>tmpsort.txt

    J.A. Coutts
    Last edited by couttsj; May 8th, 2018 at 08:28 PM.

  9. #9
    Frenzied Member
    Join Date
    Dec 2008
    Location
    Melbourne Australia
    Posts
    1,487

    Re: VB6 - Text Editor

    Quote Originally Posted by couttsj View Post
    Rob;
    Here is a version of TextEditor that does not use the FSO. It was a fairly straight forward conversion using my OpenFile routine and the Get/Put functions. Please let me know if you find any bugs/errors as it has undergone little testing.
    J.A. Coutts
    Thanks JA,
    It is working great.
    Rob

  10. #10
    Fanatic Member
    Join Date
    Aug 2016
    Posts
    678

    Re: VB6 - Text Editor

    Quote Originally Posted by couttsj View Post
    Why would you find it necessary to double quote something that is already string data?

    C:\Windows\system32\cmd.exe /c type C:\VB98\Utility\TxtEdit\logfile.txt|sort /+25>tmpsort.txt

    J.A. Coutts
    C:\Windows\system32\cmd.exe /c type C:\Program Files\logfile.txt|sort /+25>tmpsort.txt

    have Contains space,may error. you will test ?
    Attached Images Attached Images  

  11. #11

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2012
    Posts
    1,476

    Re: VB6 - Text Editor

    Quote Originally Posted by xxdoc123 View Post
    have Contains space,may error. you will test ?
    Where does this error occur? And what is the size & nature of the ErrorLog.txt? Nothing is displayed in the TextBox. A TextBox will not support Unicode characters. You may be better off with InkEditor, which uses an InkEdit control.

    J.A. Coutts

  12. #12
    Fanatic Member
    Join Date
    Aug 2016
    Posts
    678

    Re: VB6 - Text Editor

    Quote Originally Posted by couttsj View Post
    Where does this error occur? And what is the size & nature of the ErrorLog.txt? Nothing is displayed in the TextBox. A TextBox will not support Unicode characters. You may be better off with InkEditor, which uses an InkEdit control.

    J.A. Coutts
    no Unicode。


    An error occurs if the file path contains spaces. I mentioned above

    may be

    Call Shell(Environ("COMSPEC") & " /c type " & """" & m_Filename & SortCmd & """", vbHide)

    replace

    Call Shell(Environ("COMSPEC") & " /c type " & m_Filename & SortCmd, vbHide)

  13. #13
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,152

    Re: VB6 - Text Editor

    Quote Originally Posted by couttsj View Post
    Why would you find it necessary to double quote something that is already string data?
    It amazes me that quoting filenames with spaces (and other special characters) when shelling utilities on the command-line sounds like a foreign idea to you.

    You can first read this explanation: https://blogs.msdn.microsoft.com/twi...-the-wrong-way

    Then take a look at ArgvQuote implementation in VB6.

    cheers,
    </wqw>

  14. #14

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2012
    Posts
    1,476

    Re: VB6 - Text Editor

    Quote Originally Posted by xxdoc123 View Post
    no Unicode。
    An error occurs if the file path contains spaces. I mentioned above
    Thanks to proportional fonts, I did not notice the spaces in the file path. Spaces in file names/paths is something I try to avoid because of this particular issue. If I could change the name of "Program Files (x86)" and get away with it, I would. I could use progra~2, but unfortunately that's also what displays on the screen.

    Thank you for the feedback.

    J.A. Coutts

  15. #15
    Frenzied Member
    Join Date
    May 2014
    Location
    Kallithea Attikis, Greece
    Posts
    1,289

    Re: VB6 - Text Editor

    I can make it better using my own user control (I have to give a break to other tasks, but I want for fun to make it). So fellows prepare for the new version (or meanwhile prepare altenative one).

  16. #16

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2012
    Posts
    1,476

    Re: VB6 - Text Editor

    Found a bug in TextEditor relating to Find & Replace All. When the first line contains the search data at the first position, the second search fails because both the start position and the length are both zero. This is caused by the fact that "SelStart" in the API is 0-based, and "InStr" is 1-based. To alleviate this problem, add the following line ahead of the search functions in "Function Find".
    Code:
       If lPos = 0 Then lLen = 1
    J.A. Coutts

  17. #17

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2012
    Posts
    1,476

    Re: VB6 - Text Editor

    I finally got around to checking the bug fix suggested by xxdoc123. Unfortunately it times out, but it works if the double quotes are restricted to the filename only.
    Code:
        Call Shell(Environ("COMSPEC") & " /c type " & """" & m_Filename & """" & SortCmd, vbHide)
    J.A. Coutts

  18. #18
    Frenzied Member
    Join Date
    May 2014
    Location
    Kallithea Attikis, Greece
    Posts
    1,289

    VB6 - Text Editor2

    A new TextEditor. I keep the idea from J.A. Coutts, for the sorting, and replacing of lines.
    Whats New?
    1. Files Utf8/ascii/Utf16LE/UTF16GE, with automatic recognition of format (with and without BOM). Also open Linux format files too. Save to same way as open.
    2. Use of TAB. (this was difficult for the User Control, which i have made for M2000 Interpreter, because I spend 3 days to figure a solution).
    3. Syntax Highlihght for VB6 and Assembly. We can choose any time the coloring method. Work but can be better.
    4. Two printing methods. One based on Coutts code at 50%, the other 50% is the unicode support (not for right to left writing), and now print Courier New, in any language. The second method print proportional or no depends on font we have choose. Also if we use Syntax Highlight we get colors (for white background) and wrapping (only left justify, but works better for tabs too).
    5. Unlimited Undo/redo
    6. Find and Replace, with undo too.
    7. Dark/Bright textbox baclground, and there are two color sets for each
    8. We can open txt files with thousands of lines (paragraphs). Limit only from memory.
    9. Sort can be done from a line to the end, and from from that line and a column (a left position). So keys for sortin always are on right side of cursor. No need to use external file
    10 With a button F9 we get a fast counting of words
    11 We can change case of letters in a word and with F4 we can change in every line in text.
    12 with F2/F3 we shearch Up or Down.
    13. We can go to a line number.
    14 We see paragraphs (with no wrapping) or lines (with wrapping paragraphs). With F6/F7/F8 we set bookmarks. Bookmarks works at specific paragraphs, so we can insert paragraphs without loosing the bookmark.
    15. We can choose no linespace, normal or half. Also this linespace used for printing too.
    16. Show Paragraphs/hidden chars. We can see spaces as dots, non break spaces as spaces, tabs, paragraphs. We can print using this mode also. Works with syntax hoghligjt too.
    17.Mouse Wheel works fine
    18. There is no horizontal scrolling bar, because horizontal scrolling is automatic.
    19. Vertical scrolling can be done in three ways
    - by half page using wheel, page up/down, clicking on auto hidden vertical scroll bar
    - by line using pushing by holding down the left button and pushing the mouse. There is an automatic scrolling if we make big pushing. Pushing works in reverse from the vertical scrool bar.
    - Fast scrolling with scroll bar handle. This scrolling done without moving cursor, so we can go back if we press an arrow.
    20. Drag & Drop
    21. Export to Html, when we copy to clipboard. So we get the colors in Word easy.
    22. We can make a lot more, Find and replace can be use same UC, but for now they are textboxes, which get default codepage by system. The same default codepage using for ascii. So in any system the ascii text converted based on language for "non unicode supporting programs". EditBox based on a UC and a Document class can be use any codepage, so we have to make options for the ascii in use codepage.



    Thats all, for now
    George
    Attached Files Attached Files
    Last edited by georgekar; May 14th, 2018 at 08:55 PM.

  19. #19
    Frenzied Member
    Join Date
    May 2014
    Location
    Kallithea Attikis, Greece
    Posts
    1,289

    Re: VB6 - Text Editor

    Three modes: The Dark, with assembly. The bright with VB6 code and the Paragraph Show Mode.

    Name:  TextEditor.jpg
Views: 2672
Size:  69.4 KB

  20. #20
    Fanatic Member
    Join Date
    Aug 2016
    Posts
    678

    Re: VB6 - Text Editor

    Quote Originally Posted by georgekar View Post
    Three modes: The Dark, with assembly. The bright with VB6 code and the Paragraph Show Mode.

    Name:  TextEditor.jpg
Views: 2672
Size:  69.4 KB
    Cannot input Chinese character string

  21. #21
    Frenzied Member
    Join Date
    May 2014
    Location
    Kallithea Attikis, Greece
    Posts
    1,289

    Re: VB6 - Text Editor

    Try to paste text. Sorry I have not knowledge for your language.

    I am working to make it IME-aware.
    Last edited by georgekar; May 16th, 2018 at 06:59 AM.

  22. #22
    Frenzied Member
    Join Date
    May 2014
    Location
    Kallithea Attikis, Greece
    Posts
    1,289

    Re: VB6 - Text Editor

    Now we can insert chinese text. Because I have no idea about chinese, I make tests, so I leave code as is with debug.print, so any chinese member (I am thinking about xxdoc123) can use it and find any error.
    Also a change slight the wrapping so for chinese text we get wrap in any char position.
    The candidates from IME shown in the top and left corner in editbox, but this is not a problem, I think.

    Also I replace textboxes in Find and Replace with same user control, so now we can search chinese text too. Also works drag and drop between main form and search form. Also in that editboxes we can use the input method (Chinese simplified) Pinyin ABC Input Style).

    I didn't check the new version in XP os, only in Windows 7.

    I found a way to use imm32 without subclassing the User Control. So I make a proper read to result string. Also to show the roman letters before actual get the result, i use the Seltext property of Editbox class.

    George
    Attached Files Attached Files

  23. #23
    Frenzied Member
    Join Date
    May 2014
    Location
    Kallithea Attikis, Greece
    Posts
    1,289

    Re: VB6 - Text Editor

    A screen shot.
    I found a lesson from here https://www.chinaeducenter.com/en/le...e/lesson32.php
    Type Wo and open a list to choose. Look the Find and Replace with new controls for textbox (it is the same editbox but nor allow new line, and has a maximum of 50 chars.
    Name:  chinese.jpg
Views: 2785
Size:  44.6 KB

  24. #24

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2012
    Posts
    1,476

    Re: VB6 - Text Editor

    Text Editor has been updated to fix a bug that I discovered. When a text file had portions of it deleted and saved, the file length did not change from the original, and the end of the file was padded with the original data. For further info, see:

    http://www.vbforums.com/showthread.p...on-Binary-Save

    J.A. Coutts

    Note: Ink Editor will suffer from the same issue, and will also be upgraded in the near future.

  25. #25
    Frenzied Member
    Join Date
    Dec 2008
    Location
    Melbourne Australia
    Posts
    1,487

    Re: VB6 - Text Editor

    Quote Originally Posted by couttsj View Post
    Text Editor has been updated to fix a bug that I discovered. When a text file had portions of it deleted and saved, the file length did not change from the original, and the end of the file was padded with the original data. For further info, see:
    http://www.vbforums.com/showthread.p...on-Binary-Save
    J.A. Coutts
    Hi JA,
    Regarding the changes mentioned in your last post (I have included your quote).
    Did you update the version that you attached in Post 6 ('TestEdit2.zip' a non FSO version) ?

    Thanks,
    Rob

  26. #26

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2012
    Posts
    1,476

    Re: VB6 - Text Editor

    Quote Originally Posted by Bobbles View Post
    Hi JA,
    Regarding the changes mentioned in your last post (I have included your quote).
    Did you update the version that you attached in Post 6 ('TestEdit2.zip' a non FSO version) ?

    Thanks,
    Rob
    Yes, the date on my last post matches the update date on post #6 (Updated: 06/15/2018).

    J.A. Coutts

  27. #27
    Frenzied Member
    Join Date
    Dec 2008
    Location
    Melbourne Australia
    Posts
    1,487

    Re: VB6 - Text Editor

    Quote Originally Posted by couttsj View Post
    Yes, the date on my last post matches the update date on post #6 (Updated: 06/15/2018).
    J.A. Coutts
    Thank you
    Rob

  28. #28
    Addicted Member jg.sa's Avatar
    Join Date
    Nov 2017
    Location
    South Australia ( SA )
    Posts
    199

    Re: VB6 - Text Editor

    G'Day JAC

    I know this is right out of left field - pun intended, did you ever think about adding keyboard macros to this editor to process text ?

    So just a quick bit of background, I regularly create DNS entries on for a new dom. reg. on 3rd party servers via text files.

    It is embarrassing that I'm such a ( OG ) Old Guy, but I'm still using a Key. Mac. Sys. written in LotusScript I wrote in mid. '90s so I need to join 21st century.

    Maybe I should just get a native Key. Mac. app. ?

    Anyone got any experience with systems like this and are happy to set me straight ?

    TIA

  29. #29

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2012
    Posts
    1,476

    Re: VB6 - Text Editor

    Quote Originally Posted by jg.sa View Post
    G'Day JAC

    I know this is right out of left field - pun intended, did you ever think about adding keyboard macros to this editor to process text ?

    So just a quick bit of background, I regularly create DNS entries on for a new dom. reg. on 3rd party servers via text files.

    It is embarrassing that I'm such a ( OG ) Old Guy, but I'm still using a Key. Mac. Sys. written in LotusScript I wrote in mid. '90s so I need to join 21st century.

    Maybe I should just get a native Key. Mac. app. ?

    Anyone got any experience with systems like this and are happy to set me straight ?

    TIA
    The beautiful thing about writing your own text editor is that you can add whatever features you think you might need. I needed the ability to sort log files, so that is a feature I added for myself. It has its limitations, but it met my perceived needs.

    J.A. Coutts

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width