1 Attachment(s)
VB - Format your code for copying
Ever had the problem of copying VB code into a word file (or other text editor) and finding that all the colour and font formatting is lost?
Well with this you can copy the code into the rich text box and press format and it goes through the contents of the box and changes all comments to green and all the vb Keywords to blue, so it looks just like it does in the VB editor! :D
Very useful for students like myself wanting to put their in a word file for documentation for coursework etc...
EDIT: Latest version now here:
Re: VB - Format your code for copying
VERY useful, thankyou, and working well :D
Keep up the good work :)
Re: VB - Format your code for copying
Very, very nice. I added one thing, and that was to make the Keyword listbox sorted so they are displayed alphabetically.
(Once that was done I noticed that Replace and Split were missing, so I just added them to the Keyword CONST.)
This will be useful. :thumb:
Re: VB - Format your code for copying
@ Hack:
Thanks for that, i guessed id probably missed some words, ill add them in and post it again next time im online on my pc, ill add the alphabetical sort too. If anyone notices any other words missin then please post them on here so i know.
Re: VB - Format your code for copying
I added these to the Const:
¦Split¦Replace¦ParamArray¦Declare¦Select¦Me¦Resume¦On¦Error¦GoTo¦In¦Call¦Is¦Nothing¦W ith¦IsNumeric¦IsDate¦" + _
"CDec¦CBool¦CByte¦CCur¦CDate¦CDbl¦CDec¦CInt¦CLng¦CSng¦CStr¦CVar¦IsNull¦Abs¦IsEmpty¦Ty pe"
At some point, I think I going to create a Access Db table to hold them. That way, if you actually do "Add" or "Remove" a keyword, it will, or will not, be available the next time you run the program.
Re: VB - Format your code for copying
yea, the two you gave me yesterday, "Replace" and "Split" dont actually show up blue in the vb editor... i missed "With" as well from the original
Re: VB - Format your code for copying
oops just noticed you already said about "With"!
Re: VB - Format your code for copying
Quote:
Originally Posted by Arachnid13
yea, the two you gave me yesterday, "Replace" and "Split" dont actually show up blue in the vb editor... i missed "With" as well from the original
Yes, I know, but in so far as the code formatter will be for individual use, anyone can put in whatever they want as highlighted keywords. I've always felt those two should be blue anyway.
1 Attachment(s)
Re: VB - Format your code for copying
yea i guess, well here's the updated version, it sorts the listbox now and instead of using a keyword constant, it accesses the "KeywordList.txt" file, just make sure you either put the file in your vb folder (or in the same folder as the app if u compile it) or change the line "Directory = App.Path" to the directory that you have the file in... (it's in the Form_Load() event)
Re: VB - Format your code for copying
Cool. Nice catch on the "Lib" keyword by the way. I missed that one as well. :)
Re: VB - Format your code for copying
Here is what I'm currently using for keywords:
Const DEFAULT_KEYWORDS = "Dim¦Const¦Private¦Public¦Global¦As¦Boolean¦Byte¦Currency¦Date¦Double¦Empty¦Integer¦Lon g¦Single¦String¦Variant¦" + _
"For¦To¦Next¦Step¦If¦Not¦And¦Or¦Xor¦Else¦ElseIf¦End¦Then¦True¦False¦Do¦Loop¦Until¦ While¦Wend¦Sub¦Function¦Optional¦Exit¦Set¦New¦Option¦Explicit¦" + _
"Case¦Open¦Close¦Print¦Input¦Get¦Put¦Debug¦Split¦Replace¦ParamArray¦Declare¦Select¦Me¦ Resume¦On¦Error¦GoTo¦In¦Call¦Is¦Nothing¦With¦IsNumeric¦IsDate¦" + _
"CDec¦CBool¦CByte¦CCur¦CDate¦CDbl¦CDec¦CInt¦CLng¦CSng¦CStr¦CVar¦IsNull¦Abs¦IsEmpty¦Ty pe¦Lib¦IsArray"
Re: VB - Format your code for copying
Keywords copied+pasted from that wonderful piece of software, Notepad++.
There are a whole lot of VB.NET ones in there as well.
Code:
addhandler addressof andalso alias and ansi as assembly attribute
auto begin boolean byref byte byval call case catch cbool cbyte
cchar cdate cdec cdbl char cint class clng cobj compare const
continue cshort csng cstr ctype currency date decimal declare
default delegate dim do double each else elseif end enum erase
error event exit explicit false finally for friend function get
gettype global gosub goto handles if implement implements imports
in inherits integer interface is let lib like load long loop lset
me mid mod module mustinherit mustoverride mybase myclass
namespace new next not nothing notinheritable notoverridable
object on option optional or orelse overloads overridable
overrides paramarray preserve private property protected public
raiseevent readonly redim rem removehandler rset resume return
select set shadows shared short single static step stop string
structure sub synclock then throw to true try type typeof unload
unicode until variant wend when while with withevents writeonly xor
Re: VB - Format your code for copying
Cool! I added a bunch more keywords based on your thread penagate! :thumb:
Re: VB - Format your code for copying
A couple of things :
In Form_Load :
1) There is no need for Directory = "D:\", and you can use this : If Right$(Directory, 1) <> "\" Then Directory = Directory & "\" to make sure you have the backslash at the end.
2) In cmdAdd_Click, to not add anything if the user presses cancel, you can use this :
VB Code:
Private Sub cmdAdd_Click()
Dim i As Long
Dim sInput As String
sInput = InputBox("Enter a new keyword", "Arachnid Software")
If StrPtr(sInput) <> 0 Then
lstKeywords.AddItem sInput
Open Directory + "KeywordList.txt" For Output As #1
For i = 0 To lstKeywords.ListCount - 1
Print #1, lstKeywords.List(i)
Next i
Close #1
End If
End Sub
Re: VB - Format your code for copying
Quote:
Originally Posted by manavo11
A couple of things :
In Form_Load :
1) There is no need for Directory = "D:\", and you can use this : If Right$(Directory, 1) <> "\" Then Directory = Directory & "\" to make sure you have the backslash at the end.
Why not simply
Directory = App.Path & "\"
?
Re: VB - Format your code for copying
Well, will probably work just as well. You don't check if there is one at the end, you append one anyway. If there is more than one, it will still open the same folder, no difference, so you have a point :)
1 Attachment(s)
Re: VB - Format your code for copying
I thought a print option might be useful.
Re: VB - Format your code for copying
Thank you so much for this! I took out the listbox and just stored the keywords in an array and caught the 'Enter' key (ascii 13) to call the code written here. It works just like the VB editor now! Thanks!
Re: VB - Format your code for copying