VBScript Mid Function


The Mid Function returns a specified number of characters from a given input string.


  • String, a Required Parameter. Input String from which the specified number of characters to be returned.

  • Start, a Required Parameter. An Integer, which Specifies starting position of the string.

  • Length, an Optional Parameter. An Integer, which specifies the number of characters to be returned.


<!DOCTYPE html>
      <script language = "vbscript" type = "text/vbscript">
         var = "Microsoft VBScript"
         document.write("Line 1 : " & Mid(var,2) & "<br />")
         document.write("Line 2 : " & Mid(var,2,5) & "<br />")
         document.write("Line 3 : " & Mid(var,5,7) & "<br />")


When you save it as .html and execute it in Internet Explorer, then the above script will produce the following result −

Line 1 : icrosoft VBScript
Line 2 : icros
Line 3 : osoft V
Kickstart Your Career

Get certified by completing the course

Get Started