By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,164 Members | 969 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,164 IT Pros & Developers. It's quick & easy.

How to delete commented code lines ?

P: n/a
How to quickly delete commented code lines from modules, forms and reports.??

Any idea ?

thanks
Nov 13 '05 #1
Share this Question
Share on Google+
17 Replies


P: n/a
What is this for?

If you are trying to create a version of the database without any comments
so as to make it as efficient as possible for an end user, create an MDE:
Tools | Database Utilities | Make MDE
The MDE has the compiled code only, so the text cannot be edited and the
comments are absent.

For your developer version though, the comments are surely too valuable to
remove if you value your sanity in maintaining the database.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Javier Gomez" <ja*****************@gmail.com> wrote in message
news:89**************************@posting.google.c om...
How to quickly delete commented code lines from modules, forms and
reports.??

Any idea ?

thanks

Nov 13 '05 #2

P: n/a
Allen Browne wrote:
For your developer version though, the comments are surely too valuable to
remove if you value your sanity in maintaining the database.


Bah! Comments are for wimps. Code should be self documenting :-)

--
[Oo=w=oO]

Nov 13 '05 #3

P: n/a
"Trevor Best" <no****@besty.org.uk> wrote in message
news:42***********************@news.zen.co.uk...

Bah! Comments are for wimps. Code should be self documenting :-)


Hi Tr3v0r

If UBnCodnLong Then UN0Betta = True

707

:-)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
Nov 13 '05 #4

P: n/a
You guys are scaring me. I have always known that VB is an
interpretive language. I tend to be quite verbose with my comments.
Are you telling me that comments can make any kind of noticeable
difference in execution speed?
Anyway, I decided to run a very primitive benchmark.

For I = 1 To 10000
For J = 1 To 1000
For K = 1 To 100
A = Sqr(69)
Next K
Next J
Next I

I ran this (Access 2000) and it took 68 seconds. I ran it again
with twenty lines of comments in the innermost loop. Same time. Is
this a legitimate test?

Hank Reed

Nov 13 '05 #5

P: n/a
Without running a test, my expectations match your experience, that the
comments make no difference whatsoever.

Access/VBA compiles the code into quazi-machine code. This contains no
comments. The comments are retained only in the text version, where they are
meaningful for maintenance. There is therefore NO point at all in removing
the comments, and it should give no performance benefit at all.

That was the thinking behind my first reply to this poster: what for?

I think Trevor's comments suggest he understands it the same way, even if he
does have a very English sense of humour. :-)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Hank" <ha********@aol.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
You guys are scaring me. I have always known that VB is an
interpretive language. I tend to be quite verbose with my comments.
Are you telling me that comments can make any kind of noticeable
difference in execution speed?
Anyway, I decided to run a very primitive benchmark.

For I = 1 To 10000
For J = 1 To 1000
For K = 1 To 100
A = Sqr(69)
Next K
Next J
Next I

I ran this (Access 2000) and it took 68 seconds. I ran it again
with twenty lines of comments in the innermost loop. Same time. Is
this a legitimate test?

Hank Reed

Nov 13 '05 #6

P: n/a
Hank wrote:
You guys are scaring me. I have always known that VB is an
interpretive language. I tend to be quite verbose with my comments.
Are you telling me that comments can make any kind of noticeable
difference in execution speed?
Anyway, I decided to run a very primitive benchmark.

For I = 1 To 10000
For J = 1 To 1000
For K = 1 To 100
A = Sqr(69)
Next K
Next J
Next I

I ran this (Access 2000) and it took 68 seconds. I ran it again
with twenty lines of comments in the innermost loop. Same time. Is
this a legitimate test?

Hank Reed


68 seconds? Gasp! Obviously I need a new computer.

Mine took 142.294 seconds without the comments
and 142.344 seconds with the comments (20 lines).

Same results before and after compilation and compacting.

Perhaps the notion of comments making any noticeable difference in speed
is a hold over from an age when whatever script Access was using was not
so efficient in converting to P-Code and "compiling".

There may be other things to be concerned about with respect to speed.
For instance you use Sqr(69) and I use 69 ^ (1/2) ... (but not for this
test). It seems that my method is about seven times slower than yours.
Perhaps, I should be a little scared.

--
--
Lyle

"The aim of those who try to control thought is always the same. They
find one single explanation of the world, one system of thought and
action that will (they believe) cover everything; and then they try to
impose that on all thinking people."
- Gilbert Highet
Nov 13 '05 #7

P: n/a
ok I found the answer !

find & replace

Find what: '*
Replace with: (EMPTY)

use pattern matching: yes (activated)

ja*****************@gmail.com (Javier Gomez) wrote in message news:<89**************************@posting.google. com>...
How to quickly delete commented code lines from modules, forms and reports.??

Any idea ?

thanks

Nov 13 '05 #8

P: n/a
Lyle Fairfield wrote:
Mine took 142.294 seconds without the comments
and 142.344 seconds with the comments (20 lines).


How do you time this, Lyle?

Usually when I am analyzing performance of design choices, I'll slap
something in a test module that uses the datediff function with "s" as
the measure of time.

In the past I've seen other designers on this group talk about some
pretty fine time clocking like the above and wondered how?
--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me
Nov 13 '05 #9

P: n/a
Sounds dangerous.

Is there any chance your app could contain a line with an embedded single
quote?

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Javier Gomez" <ja*****************@gmail.com> wrote in message
news:89**************************@posting.google.c om...
ok I found the answer !

find & replace

Find what: '*
Replace with: (EMPTY)

use pattern matching: yes (activated)

ja*****************@gmail.com (Javier Gomez) wrote in message
news:<89**************************@posting.google. com>...
How to quickly delete commented code lines from modules, forms and
reports.??

Any idea ?

thanks

Nov 13 '05 #10

P: n/a
Tim Marshall <TI****@PurplePandaChasers.Moertherium> wrote in news:d4lfim
$k****@coranto.ucs.mun.ca:
Lyle Fairfield wrote:
> Mine took 142.294 seconds without the comments
and 142.344 seconds with the comments (20 lines).


How do you time this, Lyle?


Private Declare Function GetTickCount Lib "kernel32" () As Long
Sub wscfy()
Dim a As Double
Dim i As Long
Dim j As Long
Dim k As Long
Dim t As Long
t = GetTickCount
For i = 1 To 10000
For j = 1 To 1000
For k = 1 To 100
a = Sqr(68)
Next k
Next j
Next i
Debug.Print GetTickCount - t, a
End Sub

--
Lyle

"The aim of those who try to control thought is always the same. They find
one single explanation of the world, one system of thought and action that
will (they believe) cover everything; and then they try to impose that on
all thinking people."
- Gilbert Highet
Nov 13 '05 #11

P: n/a
Lyle Fairfield wrote:

Mine took 142.294 seconds without the comments
and 142.344 seconds with the comments (20 lines).


Only difference I could make to that code was to dim all the variables
as long except for a, which was single.

First pass, all variants took 90 seconds, second pass all declared types
took 73 seconds, closer to Hank's speed, wonder what he's got under the
bonnet (hood)? (XP2800+ here).

--
[Oo=w=oO]

Nov 13 '05 #12

P: n/a
Trevor Best wrote:
Lyle Fairfield wrote:

Mine took 142.294 seconds without the comments
and 142.344 seconds with the comments (20 lines).


Only difference I could make to that code was to dim all the variables
as long except for a, which was single.

First pass, all variants took 90 seconds, second pass all declared types
took 73 seconds, closer to Hank's speed, wonder what he's got under the
bonnet (hood)? (XP2800+ here).


I paid 2995 USD for my Commodore B Series 8088 with 256 K ram. How can
something so expensive be so slow? And those were 1982 dollars!

--
--
Lyle

"The aim of those who try to control thought is always the same. They
find one single explanation of the world, one system of thought and
action that will (they believe) cover everything; and then they try to
impose that on all thinking people."
- Gilbert Highet
Nov 13 '05 #13

P: n/a
Lyle Fairfield wrote:
I paid 2995 USD for my Commodore B Series 8088 with 256 K ram. How can
something so expensive be so slow? And those were 1982 dollars!


I remember a 448MB RAM kit for an RS6000 being 17,000, mine only had
16MB and no OS, dunno how much the machine was as it was given to me,
nice but totally useless present though :-\

--
[Oo=w=oO]

Nov 13 '05 #14

P: n/a
Why dangerous ?

I think it is more effective than dangerous.... :-)))
"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message news:<42**********************@per-qv1-newsreader-01.iinet.net.au>...
Sounds dangerous.

Is there any chance your app could contain a line with an embedded single
quote?

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Javier Gomez" <ja*****************@gmail.com> wrote in message
news:89**************************@posting.google.c om...
ok I found the answer !

find & replace

Find what: '*
Replace with: (EMPTY)

use pattern matching: yes (activated)

ja*****************@gmail.com (Javier Gomez) wrote in message
news:<89**************************@posting.google. com>...
How to quickly delete commented code lines from modules, forms and
reports.??

Any idea ?

thanks

Nov 13 '05 #15

P: n/a
The line:
rs.FindFirst "[Field2] = 'Dog' Or [Field2] = 'Cat'"
becomes
rs.Findfirst "[Field2] =

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Javier Gomez" <ja*****************@gmail.com> wrote in message
news:89**************************@posting.google.c om...
Why dangerous ?

I think it is more effective than dangerous.... :-)))
"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message
news:<42**********************@per-qv1-newsreader-01.iinet.net.au>...
Sounds dangerous.

Is there any chance your app could contain a line with an embedded single
quote?
"Javier Gomez" <ja*****************@gmail.com> wrote in message
news:89**************************@posting.google.c om...
> ok I found the answer !
>
> find & replace
>
> Find what: '*
> Replace with: (EMPTY)
>
> use pattern matching: yes (activated)

Nov 13 '05 #16

P: n/a
In any case you should use REPLACE (one by one) intead of REPLACE ALL
or you may comment your code in a deferent way for example:

'/ abcde....... etc......

and then use for find and replace became as follows

FIND: '/*
REPLACE: (EMPTY)
USE PATTERN MATCHING: activated

Now you can make use of REPLACE ALL !!!

You can use any simbol except the special ones :-))

regards
Nov 13 '05 #17

P: n/a
Lyle Fairfield wrote:
How do you time this, Lyle?

Private Declare Function GetTickCount Lib "kernel32" () As Long


A belated thank you very much for this!

--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me
Nov 13 '05 #18

This discussion thread is closed

Replies have been disabled for this discussion.