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
    forums
Old 03-24-2004, 07:45 PM   #1 (permalink)
rdove
Masked Moderator
 
rdove's Avatar
 
Join Date: May 2002
Location: Indianapolis, IN
Posts: 260
rdove is on a distinguished road
String Functions

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
__________________
~Ryan

rdove is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help for another program Androto Standard C, C++ 54 10-15-2004 07:21 AM
sorting objects arrays by object properties sde Java 28 08-05-2004 05:51 AM
From C to Java HighterDK Java 11 07-13-2004 07:15 PM
I'm having some problems with inheritance... <-- newb mik0rs Standard C, C++ 5 04-08-2003 10:54 PM


All times are GMT -8. The time now is 08:51 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting