VBScript InStr
hey,
ive done the following in visual basic, but, for some reason, it doesn't seem to work in VBScript (client side).
basically, i want to validate a string to see if it contains spaces (after trimming). if it does, i want to split a string into an array where there are spaces, and manipulate that further.
i used:
strVar = InStr(" ",strQuery)
that returns 0 for the " " (space), and 0 for any other character i use, if they occur among other characters. if any character apart from the space is at the beginning of the string, it still returns 0. it only returns 1 if the query is entirely the character.
i havent't come up to the split() yet, but i hope i dont have similar problems
help is much appreciated
detox posted this at 14:21 — 17th September 2001.
They have: 571 posts
Joined: Feb 2001
this bit of code is from irt.org it was useful to me to help get my head around it
<?php
<HTML>
<HEAD>
<TITLE> \"VBScript Demo\"</TITLE>
<script LANGUAGE=\"VBScript\">
<!--
Dim MyString, SpaceCount, Length, Position
MyString = \"This is my test string\"
SpaceCount = 0
Length = Len(MyString)
For Position = 1 to Length
If Mid(MyString, Position, 1) = Chr(32) Then ' Chr(32) equals the space character.
SpaceCount = SpaceCount + 1
End If
Next
MsgBox SpaceCount
'SpaceCount would equal 4
-->
</script>
</HEAD></BODY></HTML>
?>
NOTE the code editor always leaves off a couple of end tags.... If you are missing some there should just be a closing body and html tag
also try looking at devguru, this remains on of the best sites for info, try this dev guru
Mark Hensler posted this at 15:38 — 17th September 2001.
He has: 4,048 posts
Joined: Aug 2000
As far as I know, only IE will run VBScript client side.
detox posted this at 22:40 — 17th September 2001.
They have: 571 posts
Joined: Feb 2001
Mark is right, if you're trying to get this crossbrowser then you will have probs.
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.