Sideway
output.to from Sideway






Draft for Information Only

VBScript String Functions

Functions for manipulating string expression.

String Function

last updated 2017/9/21

Create a string of a specified number of the repeating character obtained from the first character of a given string expression specified by character argument.

Syntax

String(number, character)

Argument

numberRequired. Any valid numeric expression that is greater than or equal to zero for specifying the number of a repeating character. characterRequired. Any valid numeric expression as character code of repeating character that is a 8-bit character set between 0 and 255 inclusive. Or any string expression with the first character used as the repeating character.

Returns

Returns a Variant of the String data subtype containing a string of a specified number of a repeating character from a given string expression.

Special returns of String function:

numbercharacterreturn valueNullany charRun-time ErrorEmptyany char,Empty""""any charRun-time Error0NullRun-time Error0Empty""0""Run-time Error>0NullRun-time Error>0EmptyRun-time Error>0""Run-time Error

Remarks

  • The numeric expression of number argument can be any numeric expression greater than or equal to -0.5 and is equal to Round(number).
  • If the expression of character argument is a String data subtype, the first character of the string expression will be used as the repeating character.
  • If the expression of character argument is a numeric data subtype, the expression will be used as the charcter code of the repeating character.
  • A character string can be of any valid character.
  • For the numeric expression of the character argument, the number can be any number greater than or equal to -0.5 and is converted to a valid character code using the formula (Round(character) MOD 256)
  • For the 8-bit character set, character code 0 to 31 is control characters and character code greater than 127 is usually not compatible with other code page.

Requirement

1

Space Function

last updated 2017/9/21

Create a string of a specified number of repeating spaces.

Syntax

Space(number)

Argument

numberRequired. Any valid numeric expression that is greater than or equal to zero for specifying the number of repeating spaces.

Returns

Returns a Variant of the String data subtype containing a string of a given number of repeating spaces.

Special returns of String function:

numberreturn valueNullRun-time ErrorEmpty""""Run-time Error

Remarks

  • The numeric expression of number argument can be any numeric expression greater than or equal to -0.5 and is equal to Round(number).

Requirement

1

Examples

Examples of mathematics functions

ASP VbScript Command:
<script runat="server" language="VBScript">
Dim vars,str,cnt,cmda
cmda=array("str","String(cnt,str)","Space(cnt)")
Dim ucnt,tmp,i:ucnt=UBound(cmda):If var=1 Then:tmp="":Else:tmp="<b>vars</b>":End If:For i=0 to ucnt:tmp=tmp&"<b>"&rmv_ctrl(cmda(i))&", TypeName</b>":Next:Response.Write "Results on Microsoft Windows 8.1 Pro x64, Microsoft-IIS/8.5, VBScript Version 5.8 of page /sideway/default.asp<br />"&"<i>"&tmp&"</i>"
Function dsp_x:Dim tmp_a,tmp_b,i:If varx=0  Then:Execute vars:End If:If var=1 Then:tmp_a="":Else:tmp_a=rmv_ctrl(vars):End If:For i=0 to ucnt:tmp_b=cmd_b(cmda(i)):if i/2=fix(i/2) Then:tmp_b="<b>"&tmp_b&"</b>":End If:tmp_a=tmp_a&tmp_b:Next:Response.Write "<i>"&tmp_a&"</i>":End Function
Function rmv_ctrl(blk_str):Select Case blk_str:Case chr(0):blk_str="NUL":Case chr(1):blk_str="SOH":Case chr(2):blk_str="STX":Case chr(3):blk_str="ETX":Case chr(4):blk_str="EOT":Case chr(5):blk_str="ENQ":Case chr(6):blk_str="ACK":Case chr(7):blk_str="BEL":Case chr(8):blk_str="BS":Case chr(9):blk_str="HT":Case chr(10):blk_str="LF":Case chr(11):blk_str="VT":Case chr(12):blk_str="FF":Case chr(13):blk_str="CR":Case chr(14):blk_str="SO":Case chr(15):blk_str="SI":Case chr(16):blk_str="DLE":Case chr(17):blk_str="DC1":Case chr(18):blk_str="DC2":Case chr(19):blk_str="DC3":Case chr(20):blk_str="DC4":Case chr(21):blk_str="NAK":Case chr(22):blk_str="SYN":Case chr(23):blk_str="ETB":Case chr(24):blk_str="CAN":Case chr(25):blk_str="EM":Case chr(26):blk_str="SUB":Case chr(27):blk_str="ESC":Case chr(28):blk_str="FS":Case chr(29):blk_str="GS":Case chr(30):blk_str="RS":Case chr(31):blk_str="US":Case chr(127):blk_str="DEL":End Select:rmv_ctrl=blk_str:If IsNull(blk_str) OR IsEmpty(Blk_str) OR blk_str="" OR IsNumeric(Blk_str) Then:Else:rmv_ctrl=Replace(Replace(Replace(Replace(Replace(blk_str,"&","&amp;"),"  "," &nbsp;"),"""","&quot;"),"<","&lt;"),">","&gt;"): End If :End Function
Function cmd_b(blk_str):cmd_b="["&cmd_x(blk_str)&"], "&cmd_x("TypeName("&blk_str&")"):End Function
Function cmd_x(blk_str):On Error Resume Next:Dim xans, tmp:xans="":tmp="":execute "xans="&blk_str:If Err.Number <> 0  Then:xans=cmd_x("TypeName("&blk_str&")"):Select Case xans:Case 9::Case Else:xans="error":End Select:End If:If IsArray(xans)=False Then:cmd_x=rmv_ctrl(xans): Else:tmp=lst_arry(xans):cmd_x=trim(tmp):End If:End Function
Function lst_arry(blk_str):Dim tmp,i,q:q="""":tmp="":For i=0 to UBound(blk_str):if VarType(blk_str(i))>1 And VarType(blk_str(i))<6 Then:q="'":End If:tmp=tmp&" "&q&rmv_ctrl(blk_str(i))&q:Next:lst_arry=trim(tmp):End Function

vars="cnt=Empty:str=Empty":dsp_x
vars="cnt=0:str=Empty":dsp_x
vars="cnt=asdf:str=Empty":dsp_x
vars="cnt=Empty:str="" """:dsp_x
vars="cnt=0:str="" """:dsp_x
vars="cnt=asdf:str="" """:dsp_x
vars="cnt=Empty:str=""a""":dsp_x
vars="cnt=0:str=""a""":dsp_x
vars="cnt=asdf:str=""a""":dsp_x
vars="cnt=-0.5:str=""a""":dsp_x
vars="cnt=0.4:str=""a""":dsp_x
vars="cnt=0.5:str=""a""":dsp_x
vars="cnt=0.6:str=""a""":dsp_x
vars="cnt=1.4:str=""a""":dsp_x
vars="cnt=1.5:str=""a""":dsp_x
vars="cnt=1.6:str=""a""":dsp_x
vars="cnt=2.4:str=""a""":dsp_x
vars="cnt=2.5:str=""as""":dsp_x
vars="cnt=2.6:str=""as""":dsp_x
vars="cnt=2.5:str=""123""":dsp_x
vars="cnt=2.5:str=123":dsp_x
vars="cnt=2.5:str=123.4":dsp_x
vars="cnt=2.5:str=123.5":dsp_x
vars="cnt=2.5:str=123.6":dsp_x
vars="cnt=2.5:str=124.4":dsp_x
vars="cnt=2.5:str=124.5":dsp_x
vars="cnt=2.5:str=124.6":dsp_x
vars="cnt=2.5:str=""ÿ""":dsp_x
vars="cnt=2.5:str=""‱""":dsp_x
vars="cnt=2.5:str=254":dsp_x
vars="cnt=1.4:str=Chr(254)":dsp_x
vars="cnt=1.4:str=ChrW(254)":dsp_x
vars="cnt=1.4:str=ChrW(8694)":dsp_x
</script>
HTML Web Page In-line Output:
Results on Microsoft Windows 8.1 Pro x64, Microsoft-IIS/8.5, VBScript Version 5.8 of page /sideway/default.asp
varsstr, TypeNameString(cnt,str), TypeNameSpace(cnt), TypeNamecnt=Empty:str=Empty[], Empty[], String[], Stringcnt=0:str=Empty[], Empty[], String[], Stringcnt=asdf:str=Empty[], Empty[], String[], Stringcnt=Empty:str=" "[ ], String[], String[], Stringcnt=0:str=" "[ ], String[], String[], Stringcnt=asdf:str=" "[ ], String[], String[], Stringcnt=Empty:str="a"[a], String[], String[], Stringcnt=0:str="a"[a], String[], String[], Stringcnt=asdf:str="a"[a], String[], String[], Stringcnt=-0.5:str="a"[a], String[], String[], Stringcnt=0.4:str="a"[a], String[], String[], Stringcnt=0.5:str="a"[a], String[], String[], Stringcnt=0.6:str="a"[a], String[a], String[ ], Stringcnt=1.4:str="a"[a], String[a], String[ ], Stringcnt=1.5:str="a"[a], String[aa], String[  ], Stringcnt=1.6:str="a"[a], String[aa], String[  ], Stringcnt=2.4:str="a"[a], String[aa], String[  ], Stringcnt=2.5:str="as"[as], String[aa], String[  ], Stringcnt=2.6:str="as"[as], String[aaa], String[   ], Stringcnt=2.5:str="123"[123], String[11], String[  ], Stringcnt=2.5:str=123[123], Integer[{{], String[  ], Stringcnt=2.5:str=123.4[123.4], Double[{{], String[  ], Stringcnt=2.5:str=123.5[123.5], Double[||], String[  ], Stringcnt=2.5:str=123.6[123.6], Double[||], String[  ], Stringcnt=2.5:str=124.4[124.4], Double[||], String[  ], Stringcnt=2.5:str=124.5[124.5], Double[||], String[  ], Stringcnt=2.5:str=124.6[124.6], Double[}}], String[  ], Stringcnt=2.5:str="ÿ"[ÿ], String[ÿÿ], String[  ], Stringcnt=2.5:str="‱"[‱], String[‱‱], String[  ], Stringcnt=2.5:str=254[254], Integer[��], String[  ], Stringcnt=1.4:str=Chr(254)[�], String[�], String[ ], Stringcnt=1.4:str=ChrW(254)[þ], String[þ], String[ ], Stringcnt=1.4:str=ChrW(8694)[⇶], String[⇶], String[ ], String

Sources

  •  

©sideway

ID: 170900032 Last Updated: 2017/11/6 Revision: 2

IMAGE

Home (1)

Business

Management

HBR (3)

Information

Recreation

Hobbies (7)

Culture

Chinese (1097)

English (330)

Reference (60)

Computer

Hardware (147)new

Software

Application (184)

Digitization (22)

Numeric (19)

Programming

Web (507)

HTML

Knowledge Base

Common Color (1)

Html Entity (Unicode) (1)

Html 401 Special (1)

OS (305)new

MS Windows

Windows10 (1)

DeskTop (5)

Knowledge

Mathematics

Formulas (7)

Number Theory (51)

Algebra (14)

Trigonometry (18)

Geometry (18)

Calculus (66)

Engineering

Tables (8)

Mechanical

Control

Process Control (1)

Mechanics (1)

Rigid Bodies

Statics & Dynamics (128)

Fluid (5)

Fluid Kinematics (5)

Acoustics (19)

FiniteElement (2)

Biology (1)

Geography (1)


facebook
Latest Updated Links

Copyright © 2000-2018 Sideway . All rights reserved Disclaimersfacebook last modified on 08 Mar 2018