|
-
Sep 13th, 2000, 03:50 PM
#1
Thread Starter
Member
When is it really not necessecary to use With....End With...e.g. i use with functions such as
With Printer
.Orientation = printmode.dmOrientation
.PrintQuality = printmode.dmPrintQuality
.ColorMode = printmode.dmColor
.Copies = printmode.dmCopies
.PaperSize = printmode.dmPaperSize
.ScaleLeft = -0.5 * 1440
.ScaleTop = -0.5 * 1440
.CurrentX = 0
.CurrentY = 0
End With
but i wouldnt use it if tehre was only 3 or 4 items. Should i? What is the "standard" number of items that one should begin to use with and end with for?....does using it do anything more than save my hands some extra typing?
-
Sep 13th, 2000, 03:52 PM
#2
I usually use With...End With if there are more than 2 items.
-
Sep 13th, 2000, 03:58 PM
#3
Hyperactive Member
Use it whenever you want
Once compiled it makes no difference whatsoever whether you use the block or not. (OK you caught me thats an ASSUMPTION however if it did make a difference, then how stupid would that be!)
I have even used it when there is only one line in the block, but it added readability to the code by allowing an otherwise long line of code to be shorter.
Mind you I do have a tendancy to name my classes somewhat descriptively... plus I don't like using the _ character to split lines for some reason. I think I am too used to C++, Java, Lisp in that respect 
Cheers
Paul Lewis
-
Sep 13th, 2000, 03:59 PM
#4
_______
<?>
Not everything is laid it stone..it's a preference thing.
Less typing..easy to follow.
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Sep 13th, 2000, 04:15 PM
#5
Actually, With...End With is useful. So you don't have to type the whole thing out.
Code:
'Example:
RichTextBox1.Text = ""
RichTextBox1.SelText = "Hello World"
RichTextBox1.SelStart = 0
RichTextBox1.SelLength = Len(RichTextBox1.Text)
Can be easily typed short like this:
Code:
'Example:
With RichTextBox1
.Text = ""
.SelText = "Hello World"
.SelStart = 0
.SelLength = Len(.Text)
End With
-
Sep 13th, 2000, 05:03 PM
#6
In my opinion, it's more of a neatness and organization preference than a typing preference.
-
Sep 13th, 2000, 05:23 PM
#7
It's actually should speed up the code processing (atleast according to Micro$oft). When you use With statement, it referencing the object only once and then accessing it's properties and methods, where if you use object name explicitely, it referencing each time you call the object name.
-
Sep 13th, 2000, 05:42 PM
#8
Hyperactive Member
Good to know Serge..
That info is good to know. Microsoft say it ought to be faster which is always a bonus.
Cheers
Paul
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|