Link to home
Start Free TrialLog in
Avatar of wizard61
wizard61

asked on

tool to sort functions?

I would like a tool that re-orders the functions in my forms and modules. I like things in alphabetical sequence. Freeware would be nice :) Or can Visual Studio do this for me? Thanx-
Avatar of rspahitz
rspahitz
Flag of United States of America image

I think that VB actually does this when you add new functions/subs from Tools|Add Procedure.

As such, you could probably cut the code out and add the function, then select it and paste the code back.

Still manual and time consuming, but better than dragging.

Alternately, you can split the code window and then select and drag from one window to the next.

...
That said, it seems like a good place for a new tool.  I'd use it too if it were cheap enough (free?) although it would also be easy enough to write...like 4 hours work...hmm maybe I'll do it this weekend and make a copy available if you haven't already done the above.
Avatar of JeffGrigg
JeffGrigg

(Gosh, I really should look before I leap!  ;-)

If you can answer this question, then you'll also have the answer to...
https://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=visualbasic&qid=20159441
I've considered writing such an addin. I ain't done it yet (yes, I'm southern <grin>) because I'm still figuring out how to do addins...
I've got most of it written.  The hard part was building the interface so it's bullet-proof.  Anyone interested in having me upload it to a server somewhere?  (If not, I'll keep it for myself.)
Avatar of Éric Moreau
send it to me (emoreau99@hotmail.com) and I may upload it to a server.
When it's available on an Internet server, please post the URL here; I'm sure lots of people would be interested in using it!

ThankYouThankYouThankYouThankYouThankYou!!!
Well, then I'll just have to give it a version number.  

Maybe this will be my big break and I'll earn millions and I'll go on to be rich and famous and write a new operating system which will uproot Microsoft.

Ah, it's nice to dream.  Maybe just a shareware product.
>>>  *AFTER* it's running and up on a server,  <<<
     would you consider SourceForge?

http://sourceforge.net/
I opened a Q in the expert area for the VB Source sorter, so I can better track it and send updates:

https://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=expinput&qid=20162326

Feel free to subscribe to that one so I can pass along updates.

Meanwhile, JeffGrigg , what does SourceForge do?  I looked at it but don't understand its mission or implementation of that mission.

And wizard61, have you abandoned this Q?  How about a response?
SourceForge is a shareware repository for shareware projects.  I confess that I haven't participated in any SourceForge projects, but I've downloaded several.  ;->

What SourceForge does for you:

 > It provides server space to store and distribute your source and object code free to anyone who wants it.

 > It provides infrastructure and rules that allow you to share the development burdon with some set of software developers that you trust.  You control the list of "authorized" developers.  Everyone can contribute; it doesn't all have to be done by one person.  (See "Administering Developers for Your Project" at http://sourceforge.net/docman/display_doc.php?docid=779&group_id=1)

(Lots of documentation is available at http://sourceforge.net/docman/?group_id=1)
OK, I uploaded a preliminary version of the code sorter.  Again, for more details see

 https://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=expinput&qid=20162326

ASKER CERTIFIED SOLUTION
Avatar of rspahitz
rspahitz
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ah, but will the *SOURCE* be available?  I think it would be educational.

(For my vote on rspahitz's proposed answer:  I accepted his implementation as the "answer" to my "order of VB functions" question.)
I worked hard for that source :( Although I had most of it written in the 4 hours indicated, I put a lot of effort into making it look and act professional, so I hesitate to simply give the source away for nothing.

Jeff, contact me at my e-mail on the download site, and I'll send you a copy.
rspahitz >I worked hard for that source
Did you do market research?  ;-)

http://www.vb2themax.com/FileBank.asp?PageID=FileBank
"The Procedures Sort Add-In"
Click on diskette icon to download file ProcSort.zip (it's free, but no source)

"The Procedures Sort Add-In is a great add-in for those who like well-organized code. You can use it to sort your procedures in the active CodeWindow alphabetically. It preserve all you procedure attributes, which you normally loose when you do it manually. Event-handlers and Interface-implementations will be placed at the end of your code. You can set an option whether you want to have the constructors and destructors at the top."
>"Did you do market research?"

Sure...I querued EE ;)

>"The Procedures Sort Add-In"
Now you show up with this thing!
(And it looks good in concept, although I couldn't get it to work according to the very limited instructions.)


>I couldn't get it to work

You can install the addin by registering the DLL with the REGSVR32 utility:
        RegSvr32 ProcedureSort.dll

and then adding the following line to the VBADDIN.INI file in the \Windows directory:
        ProcedureSort.Connect=0

You have to load the Add-In using the 'Add-In Manager' in VB (Menu Tools). You will see a sort button (A-Z) in the Standard toolbar. The procedures of the active code-window will be sorted when you click this button.

Did you know that instead of using RegSvr32.Exe
- you can use references dialog to register dll (menu Project, References, Browse, and select dll file - this will register dll)
- you can use VB toolbox to register OCX - just drag OCX file from Explorer onto the toolbox.
>"The procedures of the active code-window will be sorted when you click this button."

I got that far (added the "sort" button), but when I clicked the button while the cursor was in the code window, nothing seemed to happen.  I tried it in the code window for a class and a form, but the procedures did not move from their unsorted positions.

>nothing seemed to happen
Maybe they are already sorted.  It sorts procedures OK here.
I don't know what happened before, but I reinstalled and it looks decent.  Obviously better than mine since it works on code in the VB project rather than outside.

My only complaints are that it likes to add extra spacing between my procs, and that the "undo" feature needs to be reviewed!

You can "undo" (ctrl-Z) some of the changes that it makes (since it sorts your procs in phases), which will thereby delete the most recently sorted procedure you just added--a dangerous feature...if you didn't realize what it was doing.  As such make sure to save immediately after your sort.

(A better implementation would have been to copy/paste/delete rather than cut/paste, but this is also an early version.)

--
Oh yeah, and his is 8K bigger than mine ;)
Hey, wizard61, are you with us?  You have two good solution.  Why not pick one.
Avatar of wizard61

ASKER

Sorry, I've been preoccupied. A lot to read up above. I cannt get to you links, rsparhitz. I'll try the thing from ameba. Again, sorry for the delay.
Do you mean you can't get to the EE link above or the link where I have the tool:

http://www.mjscreations.com/rjscreations/sdplug

I hope this helps.
Note that although the web page lists both the tool and the supporting file (Common Dialog Control 32), you probably already have the supporting file.
Thanks, and sorry for the delay. I have not tried it yet, but it downloaded fine. C-ya :)
Well, thanks for the points.  By all means, let me know if you have any questions related to it.

P.S. If you find that it is not as useful as ameba's choice (3 comments after the accepted answer), since mine is an off-line sorter and the link points to an on-line sorter, feel free to drop a line in the Customer Service topic area to switch the accepted answer/points.
...CS this is my acceptance of such a decision from wiard61 should it occur.

Meanwhile, feel free to offer suggestions on improving my offering.  It already allows you to add line numbering, either on all lines (except line continuations), or only those lines that don't begin with a comment.  This could certainly be useful in error-trapping routines in combination with the ERL function.
You'll also see I have other options disabled--those are just proposed ideas.

Enjoy!
>If you find that it is not as useful as ameba's choice

No, don't switch, I would hate to get B grade!
OK--I guess if you decide to switch, you'd better make in an "A"!
As a newbie here, I did not realize that "B" had the slightest shame.