Login Register


[Source] Remove comments filter_list
Author
Message
[Source] Remove comments #1
Here's a sub you can use to clean a source code from comments. It displays how long it took for the script to run and how many comments were removed.
Code:
' Sub RemoveComments(ByVal Input As String, ByVal CommentPrefix As String) Dim Time As Date = Now Dim Comments As Integer = 0 Dim Clean As String = "" Dim Code As String() = Input.Split(Environment.NewLine) For Each Line As String In Code If Line.Contains(CommentPrefix) Then Clean &= Line.Split(CommentPrefix)(0) Comments += 1 Else If Line <> "" Then Clean &= Line End If End If Next My.Computer.Clipboard.SetText(Clean) MessageBox.Show("Completed after " & DateDiff(DateInterval.Second, Time, Now) & " seconds!" _ & Environment.NewLine & _ "Removed " & Comments & " comments from the code!" _ & Environment.NewLine & _ "Output saved to clipboard!") End Sub

Usage
Code:
' RemoveComments(TextBox1.Text, "//")

Reply

RE: [Source] Remove comments #2
Or you can have it clean real comments, instead of only supporting VB.net

//
/* */
<!--
[Image: BAvhP6h.png]
Code:
[5:42:25 PM] i0xillusi0n: Breshie don't bust a nut over chloe now [5:42:31 PM] Entity: fapfapfapfapfapfapfapfapfapfap [5:42:33 PM] Jigglypuff | SL: EWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW

Reply

RE: [Source] Remove comments #3
(05-28-2013, 04:34 AM)i0xIllusi0n Wrote: Or you can have it clean real comments, instead of only supporting VB.net

//
/* */
<!--

Ah, yes. But I mostly work with VB.NET so I didn't even think about that. I'll add a solution in the OP.

Reply

RE: [Source] Remove comments #4
(05-28-2013, 04:45 AM)SQLi Wrote: Ah, yes. But I mostly work with VB.NET so I didn't even think about that. I'll add a solution in the OP.

I think it's time you move on from vb..

Reply

RE: [Source] Remove comments #5
(05-28-2013, 12:54 PM)better_than_you Wrote: I think it's time you move on from vb..

How come?

Reply

RE: [Source] Remove comments #6
(05-28-2013, 04:19 PM)SQLi Wrote: How come?

It's only supported by windows, it has less features, STILL requires updated .net framework even though it's only for windows...
As soon as I get a c++ book, I'm porting my email bomber from VB.

Reply

RE: [Source] Remove comments #7
(05-28-2013, 04:40 PM)Sinisterkid Wrote: It's only supported by windows, it has less features, STILL requires updated .net framework even though it's only for windows...
As soon as I get a c++ book, I'm porting my email bomber from VB.

I'm fine with it being only for Windows, as it's what I use. Don't mind dependencies either unless I'm writing malware that is supposed to spread.

Reply

RE: [Source] Remove comments #8
(05-28-2013, 04:40 PM)Sinisterkid Wrote: It's only supported by windows, it has less features, STILL requires updated .net framework even though it's only for windows...
As soon as I get a c++ book, I'm porting my email bomber from VB.

*cough*mono*cough*

And why would you ever want to remove comments? They're there for a reason, so you can look at code and not be like "wtf is this shit"

Reply

RE: [Source] Remove comments #9
(05-28-2013, 05:24 PM)w00t Wrote: *cough*mono*cough*

And why would you ever want to remove comments? They're there for a reason, so you can look at code and not be like "wtf is this shit"

Maybe you don't want a bunch of clutter in your code. If you can't understand the code then you probably shouldn't be coding.

Reply

RE: [Source] Remove comments #10
(05-28-2013, 06:24 PM)SQLi Wrote: Maybe you don't want a bunch of clutter in your code. If you can't understand the code then you probably shouldn't be coding.

This. I don't use comments. Although I wouldn't bother taking them out of any code if they where there.

Reply







Users browsing this thread: 1 Guest(s)