Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TRIM and MID in VBScript

Status
Not open for further replies.

searcherrr

Technical User
Nov 6, 2005
24
US
Why the hell won't this work? I have it in a VBS file on my XP SP2 system and all it does is pull up the same exact text NOT TRIMMED. Its as if the TRIM function is just not working at all and I've also been having problems getting MID to work too and it says TYPE MISMATCH but I KNOW that I'm not violating that rule.

Dim strName

strName = Trim("Known couples Pic Of us Together in Florida.jpg")

msgbox strName

Its just 3 simple lines of code. I don't get it. I get the same exact string in the msgbox - Does this work right for anyone else or am I missing something?
 
the trim function is working perfectly. trim removes trailing or leading spaces from a string, so,

Code:
Dim strName
strName = "   blah   "
MsgBox "'" & Trim( strName ) & "'"

would display a message box with the value
Code:
'blah'



*cLFlaVA
----------------------------
[tt]I already made like infinity of those at scout camp...[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
[banghead]
 
1. This works fine for me in server side ASP
2. Msgbox is a client side function, so I tested there too - it also works (in IE only of course)
3. What Language declaratios are you adding to the top of the ASP page or in the 'type' attribute of the client script block?
4. If it is ONLY in a VBS file... what are you doing in the ASP forum?? try the VBScript Forum forum329
5. What are you trying to trim in the above example? There are no extra spaces on either side of it, so the result will be the same. Trim Function Definition:
6. You state two problems, type mismatch and the function not trimming correctly (but still outputting) - which is it ?

A smile is worth a thousand kind words. So smile, it's easy! :)
 

too slow...

A smile is worth a thousand kind words. So smile, it's easy! :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top