Return to Snippet

Revision: 21984
at December 28, 2009 05:13 by choasis


Updated Code
' Count the chars in a string
' =========
response.write(len("1234567"))
' Output: 7
' =========

' Edit date
' =========
DateAdd(Interval, Amount, yourDate)
DateAdd("ww", 2, now)
DateAdd("ww", -2, now)

' Value	        Description
' ============================
' yyyy		Year
' q	        Quarter
' m	        Month
' y	        Day of the year
' d	        Day
' w	        Weekday
' ww	        Week of a year
' h	        Hour
' n	        Minute
' s        	Second
' =========

' Search in string
' =========
foo = "12.34"
response.write(instr(foo, "."))
' Output: 3
' =========

' Cut string
' =========
response.write(left("1234567", 3))
' Output: 123
response.write(right("1234567", 3))
' Output: 567
response.write(mid("1234567", 3, 2))
' Output: 34
response.write(mid("1234567", 3))
' Output: 567
' =========

' String into float
' =========
String = "12,26"
Float = CDbl(String)
Result = Float + 7.74
' =========

' String into int
' =========
String = "12,26"
Int = CInt(String)
Result = Int + 7.74
' =========

' Split string
' =========
foo = "My-Name"
bar = split(foo, "-")
response.write(bar(0) & " " & bar(1))
' Output: My Name
' =========

' Replace' =========
foo = "My-Name"
response.write(replace(foo,"-"," "))
' Output: My Name
' =========

Revision: 21983
at December 28, 2009 03:45 by choasis


Initial Code
' Count the chars in a string
' =========
response.write(len("1234567"))
' Output: 7
' =========

' Edit date
' =========
DateAdd(Interval, Amount, yourDate)
DateAdd("ww", 2, now)
DateAdd("ww", -2, now)

' Value	        Description
' ============================
' yyyy		Year
' q	        Quarter
' m	        Month
' y	        Day of the year
' d	        Day
' w	        Weekday
' ww	        Week of a year
' h	        Hour
' n	        Minute
' s        	Second
' =========

' Search in string
' =========
foo = "12.34"
response.write(instr(foo, "."))
' Output: 3
' =========

' Cut string
' =========
response.write(left("1234567", 3))
' Output: 123
response.write(right("1234567", 3))
' Output: 567
response.write(mid("1234567", 3, 2))
' Output: 34
response.write(mid("1234567", 3))
' Output: 567
=========

' String into float
' =========
String = "12,26"
Float = CDbl(String)
Result = Float + 7.74
' =========

' String into int
' =========
String = "12,26"
Int = CInt(String)
Result = Int + 7.74
' =========

' Split string
' =========
foo = "My-Name"
bar = split(foo, "-")
response.write(bar(0) & " " & bar(1))
' Output: My Name
' =========

' Replace' =========
foo = "My-Name"
response.write(replace(foo,"-"," "))
' Output: My Name
' =========

Initial URL

                                

Initial Description
A small collection of the most wanted string-functions in ASP / VB.

Initial Title
General string-functions

Initial Tags
date, search, replace

Initial Language
ASP