PDA

View Full Version : VBScript


xtremcoder
04-27-2003, 05:34 PM
how do i rezise a string :confused:

xtremcoder
04-28-2003, 03:04 AM
fixed the problem, didnt resize the string though. however, i ran into another problem. is there a way i can search a string for a specific character?

for example, given the string "0923-1093"

can i check to see if that string contains the "-" character?

FlowJack
04-28-2003, 10:30 AM
FUNCTION: InStr( )

--------------------------------------------------------------------------------
InStr(Start, String, Substring, Compare)
The InStr function returns the numeric position of the first occurrence of a specified substring within a specified string when starting from the beginning (left end) of the string.

An output of zero indicates no match.


The first argument is optional.

Start

The optional Start argument is the numeric position, counted from the left, which defines where to start the search for the substring. The search proceeds from the left to the right.


There are two mandatory arguments.

String

The String argument is the string in which you will search.


Substring

The Substring argument is the substring you are searching for.

Code:
InStr("ABCDE ABCDE", "C")

Output:
3

Code:
InStr(4, "ABCDE ABCDE", "C")

Output:
9

So in your specific example:

Code:
InStr("0923-1093", "-")

Output:
1

So if the output is > 0 then there is a dash in the string.

Hope that helps.

I Stang U
04-28-2003, 11:52 AM
strPlead = "Please try to do what you can do"

pos = InStr(strPlead, "do")
If pos > 0 Then
Response.Write "Found first occurrence of string at position " & pos
Else
Response.Write "String not found"
End If