Windows Scripting
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsSystem AdministrationWindows Scripting

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old October 30th, 2009, 05:44 AM
Ismailc Ismailc is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2008
Posts: 84 Ismailc User rank is Corporal (100 - 500 Reputation Level)Ismailc User rank is Corporal (100 - 500 Reputation Level)Ismailc User rank is Corporal (100 - 500 Reputation Level)Ismailc User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 11 h 2 m 37 sec
Reputation Power: 4
Question VBScript - Get text inside string & remove text from string

Good day, I need help.


I have 2 problems,

1. I want to return the text within a string between [ ]: "New Description [1234]" - I want the value "1234"

2. I want to remove the "[1234]" from the string, the problem is that the string differs in legth so i can't just remove the last 6 char.
"New Description [1234]"
"New Description [1234999]"
I want to return "New Description"


Please help.

Reply With Quote
  #2  
Old October 30th, 2009, 02:53 PM
June7 June7 is offline
Contributing User
Click here for more information.
 
Join Date: Apr 2009
Location: The Great Land
Posts: 535 June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 13 h 47 m 11 sec
Reputation Power: 124
Left("New Description [1234]", 15) will return "New Description"

Val(Mid("New Description [1234]", 18)) will return 1234 as a numeric

Reply With Quote
  #3  
Old November 2nd, 2009, 01:11 AM
Ismailc Ismailc is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2008
Posts: 84 Ismailc User rank is Corporal (100 - 500 Reputation Level)Ismailc User rank is Corporal (100 - 500 Reputation Level)Ismailc User rank is Corporal (100 - 500 Reputation Level)Ismailc User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 11 h 2 m 37 sec
Reputation Power: 4
Thank You - i got it going

'tmpVendor = "aObjects("VE1055VendorsLK")"
'if tmpVendor <> "avar1" then
' tmpStart = InStr(tmpVendor,"[")
' tmpEnd = InStr(tmpVendor,"]")
' tmpEnd = tmpEnd -1
' tmpChar = tmpEnd - tmpStart
' tmpStart = tmpStart + 1
'
' tmpVal = Mid(tmpVendor,tmpStart,tmpChar)
' fclabel = tmpVal
'end if

Reply With Quote
  #4  
Old November 2nd, 2009, 04:24 AM
sync_or_swim's Avatar
sync_or_swim sync_or_swim is offline
Moderator
Click here for more information.
 
Join Date: Mar 2006
Location: South Wales
Posts: 3,461 sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 1 Day 16 h 50 m 26 sec
Reputation Power: 1806
Glad you solved your problem, but you can reduce this to one line of code, eg:
Code:
tmpVal = Mid(tmpVendor, InStr(tmpVendor, "[")+1, InStr(tmpVendor, "]")-InStr(tmpVendor, "[")-1 )

Reply With Quote
  #5  
Old November 2nd, 2009, 10:44 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
ASP Free God 48th Plane (28500 - 28999 posts)
 
Join Date: Sep 2004
Location: Israel
Posts: 28,838 Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 21st Grade (Above 100000 Reputation Level)  Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2Folding Points: 549372 Folding Title: Super Ultimate Folder - Level 2
Time spent in forums: 3 Months 2 Weeks 1 Day 14 h 30 m 10 sec
Reputation Power: 2389
Quote:
Originally Posted by sync_or_swim
Glad you solved your problem, but you can reduce this to one line of code, eg:
Code:
tmpVal = Mid(tmpVendor, InStr(tmpVendor, "[")+1, InStr(tmpVendor, "]")-InStr(tmpVendor, "[")-1 )

--moved to the Windows Scripting forum, VB forum is for question about Visual Basic like VB6, not VBScript.

IMO few lines are better than one in this case, to have readable code.
programmers are not machines, they need to understand the meaning
behind the code and having it all in one line make it very difficult.
Comments on this post
Nilpo agrees: It also makes separate entry points when debugging.

Reply With Quote
Reply

Viewing: ASP Free ForumsSystem AdministrationWindows Scripting > VBScript - Get text inside string & remove text from string


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump





 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek