|
-
Oct 6th, 2000, 08:47 AM
#1
Thread Starter
Addicted Member
Hello!
I've seen some ppl here using With, for instance
With CommonDialog1
.Flags = ...
and so on.
What's the point with this?
Is there a special benefit with using With, and when should you use it?
Thanks in advance,
Pentax
Wilhelm Tunemyr,
Swede in London
[email protected]
"Dort, wo man Bücher verbrennt, verbrennt man am Ende auch Menschen"
Heinrich Heine (1797-1856)
Pravda vítezi!
(Truth prevails!)
-
Oct 6th, 2000, 08:54 AM
#2
transcendental analytic
You use with so that you don't have to type
text1.bla1=..
text1.bla2=..
text1.bla3=..
all the time, instead you type
with text1
.bla1=...
.bla2=...
.bla3=...
end with
You can do this for objects with properties, and UDT's
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Oct 6th, 2000, 08:55 AM
#3
_______
<?>
Saves repeditive typing:
ie
Data1.Recordset.movelast
data1.recordset.addnew
data1.recordset!myRec = text1
data1.recordset.update
or
With data1.recordset
.movelast
.addnew
etc.
Late for dinner..I have to improve my typing speed.
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Oct 6th, 2000, 09:28 AM
#4
And using With ... is a bit quicker then accessing the same object over and over again.
-
Oct 6th, 2000, 12:24 PM
#5
Fanatic Member
You can also nest WITH statements when you are changing properties on a single object.
"WITH" can help make your code look a little cleaner if you are making a lot of changes on one object.
Instead of :
Code:
Private Sub Command1_Click()
Text1.Height = 100
Text1.Text = "Sample"
Text1.Font.Bold = True
End Sub
Code:
Private Sub Command1_Click()
With Text1
.Height = 100
.Text = "Sample"
With .Font
.Bold = True
End With
End With
End Sub
And, as mentioned earlier, there is a slight performance gain in using WITH since the name of the object does not need to be requalified for each statement.
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
|