Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - How to extract sub-strings?

Reply
 
Old 03-28-2009   #1 (permalink)
Thomas Lebrecht


 
 

How to extract sub-strings?

How can I extract substrings from strings?

Especially I am searching for methods to...

1.) extract a substring with a known start position until the unknown end of the source string

2.) extract the last 3 chars of a string of unknown length

Thomas


My System SpecsSystem Spec
Old 03-28-2009   #2 (permalink)
Dirk Stegemann


 
 

Re: How to extract sub-strings?

Hi Thomas,
Quote:

> Especially I am searching for methods to...
>
> 1.) extract a substring with a known start position until the unknown end of the source string
var = Mid(string, 3, Len(string)- 3)+1)

Here ia a little Testsctipt...

Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFolder = oFSO.GetFolder(".")
For Each oFile In oFolder.Files
sFilename = Left(oFile.Name, InStr(oFile.Name, ".") -1)
sEndung = Mid(oFile.Name, InStr(oFile.Name, "."), _
Len(oFile.Name)- InStr(oFile.Name, ".")+1)
sFilename = sFilename & "1" & sEndung
If MsgBox("Datei """ & oFile.Name & """ wird in """ _
& sFilename & """ umbenannt.", _
1, "Bestätigung") <> 1 _
Then WScript.Quit
If Not oFSO.Fileexists(sFilename) Then
oFSO.CopyFile oFile, sFilename
End If
Next
Quote:

> 2.) extract the last 3 chars of a string of unknown length
>
var = right(string, 3)

HTH

Dirk

My System SpecsSystem Spec
Old 03-28-2009   #3 (permalink)
Pegasus [MVP]


 
 

Re: How to extract sub-strings?


"Thomas Lebrecht" <t.lebrecht@xxxxxx> wrote in message
news:49cddb29$0$31346$9b4e6d93@xxxxxx-online.net...
Quote:

> How can I extract substrings from strings?
>
> Especially I am searching for methods to...
>
> 1.) extract a substring with a known start position until the unknown end
> of the source string
>
> 2.) extract the last 3 chars of a string of unknown length
>
> Thomas
I recommend you download the file script56.chm. It lists all basic VB Script
functions, with examples.


My System SpecsSystem Spec
Old 03-28-2009   #4 (permalink)
Todd Vargo


 
 

Re: How to extract sub-strings?


"Dirk Stegemann" <dsgrafik@xxxxxx> wrote in message
news:u0WGgD4rJHA.5912@xxxxxx
Quote:

> Hi Thomas,
>
Quote:

> > Especially I am searching for methods to...
> >
> > 1.) extract a substring with a known start position until the unknown
end of the source string
Quote:

>
> var = Mid(string, 3, Len(string)- 3)+1)
The number of characters to read is optional. If omitted, Mid will read to
the end of the string by default.

var = Mid(string, startposition)

--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
compare strings VB Script
-f paramater in strings PowerShell
Comparing strings - is it a bug? PowerShell
Resource strings PowerShell
extract vista I can extract vista from the iso file but can not ex Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46