VBScript String Function



String

The String Function fills a string with the specified character the specified number of times.

Syntax

String(number,character)
  • Number, a Required Parameter. An integer value, which would be repeated for the specified number of times against the character parameter.

  • Character, a Required Parameter. Character value, which has to be repeated for the specified number of times.

Example

<!DOCTYPE html>
<html>
   <body>
      <script language = "vbscript" type = "text/vbscript">
         document.write("Line 1 :" & String(3,"$") & "<br />")
         document.write("Line 2 :" & String(4,"*") & "<br />")
         document.write("Line 3 :" & String(5,100) & "<br />")
         document.write("Line 4 :" & String(6,"ABCDE") & "<br />")

      </script>
   </body>
</html>

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

Line 1 :$$$
Line 2 :****
Line 3 :ddddd
Line 4 :AAAAAA
vbscript_strings.htm
Advertisements