Sideway
output.to from Sideway






Draft for Information Only

VBScript String Functions

Functions for manipulating string expression.

LTrim Function

last updated 16Sep2017

Create a left trimmed string from a given string expression by removing all leading spaces on the left side of a string.

Syntax

LTrim(string)

Arguments

stringRequired. Any valid string expression which is used for copying the trimmed string from.

Returns

Returns a Variant of the String data subtype containing the left trimmed string from a given string expression by removing all leading spaces on the left side of a string.

Special returns of LTrim function:

stringreturn valueNullNullEmpty""""""

Remarks

  • always returns a string.
  • If string expression contains Null, Null is returned.
  • If string expression contains only space characters, a string with no character is returned.
  • If string expression is a numeric expression, the numeric expression is first converted to standard form and then convert to a string expression.

Requirement

Version 1

RTrim Function

last updated 16Sep2017

Create a right trimmed string from a given string expression by removing all trailing spaces on the right side of a string.

Syntax

RTrim(string)

Arguments

stringRequired. Any valid string expression which is used for copying the trimmed string from.

Returns

Returns a Variant of the String data subtype containing the right trimmed string from a given string expression by removing all trailing spaces on the right side of a string.

Special returns of LTrim function:

stringreturn valueNullNullEmpty""""""

Remarks

  • always returns a string.
  • If string expression contains Null, Null is returned.
  • If string expression contains only space characters, a string with no character is returned.
  • If string expression is a numeric expression, the numeric expression is first converted to standard form and then convert to a string expression.

Requirement

Version 1

Trim Function

last updated 16Sep2017

Create a trimmed string from a given string expression by removing both leading and trailing spaces on both sides of a string.

Syntax

Trim(string)

Arguments

stringRequired. Any valid string expression which is used for copying the trimmed string from.

Returns

Returns a Variant of the String data subtype containing the trimmed string from a given string expression by removing both leading and trailing spaces on both sides of a string.

Special returns of Trim function:

stringreturn valueNullNullEmpty""""""

Remarks

  • always returns a string.
  • If string expression contains Null, Null is returned.
  • If string expression contains only space characters, a string with no character is returned.
  • If string expression is a numeric expression, the numeric expression is first converted to standard form and then convert to a string expression.

Requirement

Version 1

Examples

Examples of Trim function

ASP VbScript Command:
<script runat="server" language="VBScript">
Dim vars,str,cnt,cmda,var:var=0
cmda=array("str","LTrim(str)","Len(LTrim(str))","RTrim(str)","Len(RTrim(str))","Trim(str)","Len(Trim(str))")
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>"&cmda(i)&", TypeName</b>":Next:Response.Write "Results on Microsoft Windows 8.1 Pro x64, VBScript Version 5.8<br />"&"<i>"&tmp&"</i>"
Function dsp_x:Dim tmp_a,tmp_b,i:If Len(vars)>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:tmp="":For i=0 to UBound(blk_str):tmp=tmp&" """&rmv_ctrl(blk_str(i))&"""":Next:lst_arry=trim(tmp):End Function

vars="str=Null":dsp_x
vars="str=Empty":dsp_x
vars="str=""""":dsp_x
vars="str=  123  ":dsp_x
vars="str=""  123  """:dsp_x
vars="str=123":dsp_x
vars="str=""123""":dsp_x
vars="str=12000":dsp_x
vars="str=""12000""":dsp_x
vars="str=1.2E124":dsp_x
vars="str=""1.2E124""":dsp_x
vars="str=""    """:dsp_x
vars="str=""    a   """:dsp_x
</script>
HTML Web Page In-line Output:
Results on Microsoft Windows 8.1 Pro x64, VBScript Version 5.8
varsstr, TypeNameLTrim(str), TypeNameLen(LTrim(str)), TypeNameRTrim(str), TypeNameLen(RTrim(str)), TypeNameTrim(str), TypeNameLen(Trim(str)), TypeNamestr=Null[], Null[], Null[], Null[], Null[], Null[], Null[], Nullstr=Empty[], Empty[], String[0], Long[], String[0], Long[], String[0], Longstr=""[], String[], String[0], Long[], String[0], Long[], String[0], Longstr=  123  [123], Integer[123], String[3], Long[123], String[3], Long[123], String[3], Longstr="  123  "[ 123 ], String[123 ], String[5], Long[ 123], String[5], Long[123], String[3], Longstr=123[123], Integer[123], String[3], Long[123], String[3], Long[123], String[3], Longstr="123"[123], String[123], String[3], Long[123], String[3], Long[123], String[3], Longstr=12000[12000], Integer[12000], String[5], Long[12000], String[5], Long[12000], String[5], Longstr="12000"[12000], String[12000], String[5], Long[12000], String[5], Long[12000], String[5], Longstr=1.2E124[1.2E+124], Double[1.2E+124], String[8], Long[1.2E+124], String[8], Long[1.2E+124], String[8], Longstr="1.2E124"[1.2E124], String[1.2E124], String[7], Long[1.2E124], String[7], Long[1.2E124], String[7], Longstr="    "[    ], String[], String[0], Long[], String[0], Long[], String[0], Longstr="    a   "[    a   ], String[a   ], String[4], Long[    a], String[5], Long[a], String[1], Long

Sources


┬ęsideway

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

IMAGE

Home (1)

Business

Management

HBR (3)

Information

Recreation

Hobbies (7)

Culture

Chinese (1013)new

English (330)

Reference (57)

Computer

Hardware (111)

Software

Application (169)

Digitization (20)

Numeric (19)

Programming

Web (376)

HTML

Knowledge Base

Common Color (1)

Html Entity (Unicode) (1)

OS (263)

MS Windows

Windows8.1 (1)

DeskTop (5)

Knowledge

Mathematics

Formulas (6)

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)

Valid XHTML 1.0 Transitional Valid CSS!
Nu Html Checker Firefox53 Chromena IExplorerna


facebook
Latest Updated Links

Copyright © 2000-2017 Sideway . All rights reserved Disclaimersfacebook last modified on 19 May 2015