With...End With: Difference between revisions

From NSB App Studio
Jump to navigation Jump to search
(Removed related items.)
No edit summary
Line 7: Line 7:
With allows you to do a series of operations on an object without having to name the object each time.  
With allows you to do a series of operations on an object without having to name the object each time.  


== Example ==
== Example (Basic) ==


<pre>
<pre>
Rem With sample
Rem With sample
'With statement allows accessing properties on a specified object
Dim theURL, theTitle
With document
With document
  Print .URL
  theURL = .URL
   Print .title
  .title = "New Title"
   Print .doctype
  theTitle = .title
   document.write(.URL & "<br>")
   document.write(.title & "<br>")
End With
End With
</pre>
== Example (JavaScript) ==
<pre>
// With sample
/* With statement allows accessing properties on a specified object */
var theURL, theTitle;
with (document) {
  theURL = URL;
  title = "New Title";
  theTitle = title;
  document.write(URL + "<br>");
  document.write(title + "<br>");
}
</pre>
</pre>


Line 22: Line 44:
<pre>
<pre>
File:///C:Browse.htm
File:///C:Browse.htm
Test
New Title
[objectDocumentType]
</pre>
</pre>



Revision as of 06:34, 12 May 2013

With object

[statements]

End With

Description

With allows you to do a series of operations on an object without having to name the object each time.

Example (Basic)

Rem With sample
'With statement allows accessing properties on a specified object

Dim theURL, theTitle
With document
   theURL = .URL
   .title = "New Title"
   theTitle = .title
  document.write(.URL & "<br>")
  document.write(.title & "<br>")
End With

Example (JavaScript)

// With sample
/* With statement allows accessing properties on a specified object */

var theURL, theTitle;
with (document) {
   theURL = URL;
   title = "New Title";
   theTitle = title;
  document.write(URL + "<br>");
  document.write(title + "<br>");
}

Output

File:///C:Browse.htm
New Title