![]() |
|
[Source] Remove comments - Printable Version +- Sinisterly (https://sinister.ly) +-- Forum: Coding (https://sinister.ly/Forum-Coding) +--- Forum: Visual Basic & .NET Framework (https://sinister.ly/Forum-Visual-Basic-NET-Framework) +--- Thread: [Source] Remove comments (/Thread-Source-Remove-comments) Pages:
1
2
|
[Source] Remove comments - SQLi - 05-28-2013 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 SubUsage Code: '
RemoveComments(TextBox1.Text, "//")RE: [Source] Remove comments - i0xIllusi0n - 05-28-2013 Or you can have it clean real comments, instead of only supporting VB.net // /* */ <!-- RE: [Source] Remove comments - SQLi - 05-28-2013 (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. RE: [Source] Remove comments - yokai_old - 05-28-2013 (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.. RE: [Source] Remove comments - SQLi - 05-28-2013 (05-28-2013, 12:54 PM)better_than_you Wrote: I think it's time you move on from vb.. How come? RE: [Source] Remove comments - ErroraBorealis - 05-28-2013 (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. RE: [Source] Remove comments - SQLi - 05-28-2013 (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... 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. RE: [Source] Remove comments - w00t - 05-28-2013 (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... *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" RE: [Source] Remove comments - SQLi - 05-28-2013 (05-28-2013, 05:24 PM)w00t Wrote: *cough*mono*cough* 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. RE: [Source] Remove comments - ErroraBorealis - 05-28-2013 (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. |