Site Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
developer:vbsstatements [2015/09/25]
sandy
developer:vbsstatements [2015/09/25] (current)
sandy
Line 9: Line 9:
 Many scripting and programing languages such as JScript, C#, and C++ do not attempt to match the code of the actual physical lines typed into the text editor. This is because they do not recognize the end of a line of code until they see the termination character (in these cases, the semicolon). So, the actual physical lines of type taken up by the code are irrelevant. Many scripting and programing languages such as JScript, C#, and C++ do not attempt to match the code of the actual physical lines typed into the text editor. This is because they do not recognize the end of a line of code until they see the termination character (in these cases, the semicolon). So, the actual physical lines of type taken up by the code are irrelevant.
  
-By contrast, VBScript uses the //carriage return// instead of a special line termination character. To end a statement in VBScript, you do not have to type in a semicolon or other special character. You simply press **Enter**. For example, this code will generate a syntax error:+By contrast, VBScript uses the //carriage return// instead of a special line termination character. To end a statement in VBScript, you do not have to type in a semicolon or other special character. You simply press **Enter**. ​ 
 + 
 +For example, this code will generate a syntax error:
  
 <code vb> <code vb>
Line 24: Line 26:
 </​code>​ </​code>​
  
-In general, not requiring a statement termination character simplifies script writing in VBScript. But there is one complication:​ To enhance readability,​ we recommend that you limit the length of any single line of code to 80 characters. ​But what happens if you have a line of code that contains more than 80 characters?+In general, not requiring a statement termination character simplifies script writing in VBScript. But there is one complication:​ To enhance readability,​ we recommend that you limit the length of any single line of code to 80 characters. ​What happens if you have a line of code that contains more than 80 characters?
  
 Although it might seem like the obvious solution, you cannot split a statement into multiple lines with a carriage return. For example, the following code snippet returns a run-time error in VBScript because a statement was split by using **Enter**. Although it might seem like the obvious solution, you cannot split a statement into multiple lines with a carriage return. For example, the following code snippet returns a run-time error in VBScript because a statement was split by using **Enter**.
Line 36: Line 38:
 You cannot split a statement into multiple lines in VBScript with **Enter** because VBScript sees a carriage return as marking the end of a statement. In the preceding example, VBScript interprets the first line as the first statement in the script. Next, it interprets the second line as the second statement in the script. The error occurs because //​strUserLastName//​ is not a valid VBScript statement. You cannot split a statement into multiple lines in VBScript with **Enter** because VBScript sees a carriage return as marking the end of a statement. In the preceding example, VBScript interprets the first line as the first statement in the script. Next, it interprets the second line as the second statement in the script. The error occurs because //​strUserLastName//​ is not a valid VBScript statement.
  
-Instead, use the **underscore** (_) to indicate that a statement continues on the next line. In the revised version of the script, a blank space and an underscore indicates that the statement started on line 1 continues on line 2. To make it more clear that line 2 is a continuation of line 1, line 2 is also indented four spaces. (This is for improved readability, but you do not have to indent continued lines.)+Instead, use the **underscore** (_) to indicate that a statement continues on the next line. In the revised version of the script, a blank space and an underscore indicates that the statement started on line 1 continues on line 2. To make it more clear that line 2 is a continuation of line 1, line 2 is also indented four spaces. (This is not necessary, but does improve readability.)
  
 <code vb> <code vb>
Line 58: Line 60:
   - Add quotation marks before continuing the statement.   - Add quotation marks before continuing the statement.
  
-These quotation marks show that this line should be part of the quoted string started on the previous line. Without the quotation marks, the script engine ​would interpret the continued line as a VBScript statement. Because this is not a valid VBScript statement, an error would occur.+These quotation marks show that this line should be part of the quoted string started on the previous line. Without the quotation marks, the script engine ​will interpret the continued line as a VBScript statement. Because this is not a valid VBScript statement, an error will occur.
  
 The revised statement looks like this: The revised statement looks like this:
developer/vbsstatements.txt · Last modified: 2015/09/25 by sandy