Jump to content

VBS substring


Recommended Posts


Right(string,y) function to get the right side of string to len y

Left(string,y) to get the left side of string for len y

Mid(string, x, [len y]) to get substring from the point x to len y, if y is omitted go to end of string.

Link to comment
Share on other sites

You could also use the Split method or Split and Replace methods

Example

You have this path

C:\SomeFolder\Folder\Name.Ext

Example Split

Dim F1, F2, F3
F1 = Split("C:\SomeFolder\Folder\Name.Ext","\")
For Each F2 In F1
F3 = F2
Next
F1 = Split(F3,".")
WScript.Echo F1(0) & vbCrLf & F1(1)

Example Split And Replace

Dim F1, F2, F3
F1 = Split("C:\SomeFolder\Folder\Name.Ext","\")
For Each F2 In F1
F3 = Replace(F2,".Ext","")
Next
WScript.Echo F3

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...