The string and date operation correlation functions of VBS _VBS

Source: Internet
Author: User
Tags dateformat
1. ASC (x), CHR (x): convert character, character code
2. Filter: Searching for a specific string in a string array
Format: V=filter (X,s[,include[,compare]])
Instance:
Dim x () ={"Kjwang", "wangkj", "Peter"}
Dim V
V=filter (x, "kj") ' Result V (0) = "Kjwang", V (1) = "WANGKJ"
V=filter (x, "KJ", false) ' result V (0) = "Peter"
V=filter (x, "kj", True,vbtextcompare) ' Search by case
3. INSTR: Looking for a string position (InStrRev: Upside down for a string)
Format:
V=instr (x,y) ' to find the position of the Y string from the 1th character of the x string
V=instr (n,x,y) ' to find the position of the Y string from the nth character of the X string
Format:
V=instrrev (X,s[,n[,compare]])
4. Join: Connect a string
Format: V=join (X[,d]) ' d as separator character
5. Len (x): Calculate the length of the string x
Format: V=len (x)
6. Left (X,n): Returns the N-character (corresponding to right (X,n)) of the string X
7. Mid: Reading characters in the middle of a string X
Format: V=mid (x,n,m)
8. LTrim (x), Rtim (x), Trim (x) White-space character
9. Replace: String substitution
Format: V=replace (X,S,R)
Example: x= "I saw a saw a saw"
V=replace (x, "saw", "so") ' v= ' L so "a"
Split: String segmentation
Format: V=split (S[,d])
Example: V=split ("Vb.net,iis6.0,asp.net", ",")
' Result V (0) = "vb.net", V (1) = "iis6.0", V (2) = "asp.net"
StrReverse: Reverse String
Example: V=strreverse ("Kjwang") ' v= ' GNAWJK
UCase (x), LCase (x): Changing the case of English letters
Example: x= "HELLO,VB Chinese!"
V=ucase (x) ' v= ' HELLO,VB Chinese! "
' Date Related:
1. Take out date Time
1) DateValue (x), TimeValue (x)
Format: V=datevalue (x): Removed "date" section
V=timevalue (x) ' class
2) year (x), Month (x), day (x)
Format: v=year (x)
V=month (x)
V=day (x)
Hour (x), Minute (x), Second (x): When taken out, minutes, seconds
3) DateSerial (y,m,d): Date of merging year, month and day
Instance: Dim V
V=dateserial (1996,10,5) ' V=1996/10/5
TimeSerial (H,m,s): Time of merging, minutes, seconds
2. Now: Read system date Time
Format: V=now
3. Timer: The number of seconds elapsed since the early morning 12:00:00am
Format: V=timer
4. DatePart (p,x): Take out the values of each part of the year, month, day, etc.
Example: Dim x= #2/10/1996 16:45:30#
V=datepart ("yyyy", X) ' v=1996 year
V=datepart ("M", X) ' v=2 month
V=datepart ("D", X) ' V=10 Day
V=datepart ("H", X) ' v=16
V=datepart ("n", X) ' v=45
V=datepart ("s", X) ' v=30 seconds
V=datepart ("Q", X) ' v=1 season (first season, spring)
V=datepart ("Y", X) ' V=41 Day (41st Day of 1996)
V=datepart ("ww", X) ' V=6 Week (6th week of 1996)
V=datepart ("W", X) ' V=7 (7th Day of 6th Week, Saturday)
5. DATEADD (p,n,x): Add and subtract the new date time after some time
Format: V=dateadd (p,n,x) ' p value ibid.: "yyyy", "M", etc.
Example: Dim x= #1/31/1996 16:45:30#
V=dateadd ("yyyy", -3,x) ' minus 3 years, V=1993/1/31 16:45:30
6. DateDiff (P,X1,X2): Calculates the difference ' p value of two datetime times
Example: Dim x1= #12/31/1996 16:45:30#
x2= #2/10/1997 9:30:50#
V=datediff ("yyyy", x1,x2) ' V=1 year
7. FormatDateTime: Format of date Time
Format: V=formatdateyime (x[, date format))
Date format values: Dateformat.generaldate, Dateformat.longdate,
Datefotmat.shortdate, Dateformat.longtime, Dateformat.shorttime
8. MonthName: Returns the name of the month
Example: V=monthname (5) ' v= ' May '
9. WeekdayName: Return week name ' usage same as 8.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.