Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the functions related to string and date operation in VBS

2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces the VBS string and date operation related functions, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor with you to understand.

1. Asc (x), Chr (x): converted characters, character codes

2. Filter: searches for specific strings in an array of strings

Format: v=filter (xmems [, include [, compare]])

Example:

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 regardless of case

3. InStr: find the position of the string (InstrRev: look for the string upside down)

Format:

V=instr (XBI y) 'find out the location of the y string from the first character of the x string

V=instr (nMagnex _ y) 'find out the location of the y string from the nth character of the x string.

Format:

V=InstrRev (XMagna s [, n [, Compare]])

4. Join: concatenates strings

Format: v=join (x [, d]) 'd is a delimited character

5. Len (x): calculates the length of the string x

Format: v=len (x)

6. Left (xQuery n): returns the string x, n characters to the left (corresponding to Right (xmenn))

7. Mid: read the characters in the middle of the string x

Format: v=mid (xmeng npene m)

8. LTrim (x), RTim (x), Trim (x) whitespace characters

9. Replace: string substitution

Format: v=Replace (xmeme _ r)

Example: X = "i saw a saw a saw"

V=replace (x, "saw", "so") v = "i so a so a so"

10. 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"

11. StrReverse: reverses the string

Example: v=strreverse ("kjwang") v = "gnawjk"

12. UCase (x), LCase (x): change the case of English letters

Example: X = "hello,VB Chinese!"

V=UCase (x) v = "HELLO,VB Chinese!"

'date related:

1. Take out date and time

1) DateValue (x), TimeValue (x)

Format: v=DateValue (x): the date section of the check-out

On class v=timevalue (x)'

2) Year (x), Month (x), Day (x)

Format: v=Year (x)

V=Month (x)

V=Day (x)

Hour (x), Minute (x), Second (x): when taking out, minutes, seconds

3) DateSerial (Y _ MagneM _ D): merge the year, month and day into the date

Example: Dim v

V=DateSerial (1996, 10, 5) 'vain, 1996, 10, 5.

TimeSerial (Hrecom Mpens): merging hours, minutes, and seconds into time

2. Now: read the system date and time

Format: v=now

3. Timer: the number of seconds that have elapsed since 12:00:00AM in the morning

Format: v=timer

4. DatePart (ppencil x): take out the values of each part such as year, month, day, etc.

Example: Dim Xerox Spain 2 Universe 10 racer 1996 16 purl 45 purl 3 months

V=DatePart ("yyyy", X) v = 1996

V=DatePart ("m", X) 'v = February

V=DatePart ("d", X) 'v = 10

V=DatePart ("h", X) 'vain 16

V=DatePart ("n", X) v = 45

V=DatePart ("s", X) 'vain'30 seconds

V=DatePart ("Q", X) 'v = 1 season (first season, spring)

V=DatePart ("y", X) 'v = 41 days (41st day in 1996)

V=DatePart ("ww", X) 'v = 6 weeks (week 6 of 1996)

V=DatePart ("w", X) 'VIP7 (the seventh day of week 6, Saturday)

5. DateAdd (pmenaine x): the new date time after adding or subtracting a certain amount of time

Format: v=DateAdd (pMagneol x)'p values are the same as above, such as "yyyy", "m", etc.

Example: Dim Xerox racing, 31 racing, 1996, 16, 45, 15, 3.

V=dateadd ("yyyy",-3jue x) 'minus 3 years, vault 1993, Grease, 31 16:45:30.

6. DateDiff (pquotient x1recoveryx2): calculate the difference between two dates and times'p value as above

Example: dim x1 players 12 Universe 31 balloons 1996 16 purse 45 purl 3 races

X2hammer 2Compact 10Compact 1997 9Rod 30 purl 5mm

V=datediff ("yyyy", x1jue x2) 'v = 1 year

7. FormatDateTime: formatting date and time

Format: v=formatdateyime (x [, date format])

Date format values: DateFormat.GeneralDate, DateFormat.LongDate,

DateFotmat.ShortDate 、 DateFormat.LongTime 、 DateFormat.ShortTime

8. MonthName: returns the month name

Example: v=monthname (5) v = "May"

9. WeekDayName: return the name of the week 'with the same usage as 8.

Thank you for reading this article carefully. I hope the article "what are the functions related to string and date manipulation in VBS" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report