Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    asp
  » String Functions
      by rdove
 Page 1 of 1 
   

(Login to remove green text ads)
This tutorial is going to cover string functions. There are several different string functions, but the scope of this tutorial is going to be limited to Len, Instr, Replace, and Split.

The first function, Len, will return the length of the characters in a string including any spaces within the string.

Example:
Code:
strVariable = "This is my string" intCharsInString = Len(strVariable) ' intCharsInString = 17
Next is the Instr function. This function will return the placement number of the first occurance of a specified string within a string.

Example:
Code:
strVariable = "This is my string" intCharsInString = Instr("s", strVariable) ' intCharsInString = 4
OUr next function is the Replace function. This function will replace a value in a string based on the string critera you give it.

Example:
Code:
strVariable = "This is my string" strCharsReplaced = Instr(strVariable, "string", "tutorial") ' strCharsReplaced = This is my tutorial
And finally we have the Split function. The split function will separate a given string within a string value into an array.

Example:
Code:
strVariable = "This is my string" strCharsSplit = Split(strVariable, " ") ' strCharsSplit(0) = This ' strCharsSplit(1) = is ' strCharsSplit(2) = my ' strCharsSplit(3) = string
I hope this gives you some insite on how you can manipulate and get information from strings using ASP and VBScript.

Tutorial by:
Ryan Wischmeyer, 2004
Indianapolis, IN




 
 Page 1 of 1 
   

Rate This Article
1 2 3 4 5 6 7 8 9 10





Copyright © 2000-2006, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting
Open Circle