|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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. |
|
#2
|
|||
|
|||
|
Left("New Description [1234]", 15) will return "New Description"
Val(Mid("New Description [1234]", 18)) will return 1234 as a numeric |
|
#3
|
|||
|
|||
|
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 |
|
#4
|
||||
|
||||
|
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 ) |
|
#5
|
||||
|
||||
|
Quote:
--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. ![]() |
![]() |
| Viewing: ASP Free Forums > System Administration > Windows Scripting > VBScript - Get text inside string & remove text from string |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|