Thursday, April 17, 2014

Understand: Split and UBOUND functions


 'Split - Returns a zero-based, one-dimensional array containing a specified number of substrings.
strString = Split(strString, "\")

 'UBound - Returns the highest available subscript for the indicated dimension of an array.
For i = 0 To UBound(strString) - 1
     strNewPath = strNewPath & strString(i) & "\"
Next


4/23/2014..
today I have found that there are lbound and Ubound functions, that will give you lower bound and upper bound values.


Thursday, April 10, 2014

Understand Regex: "(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)[0-9]{2}"

"(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)[0-9]{2}"

Here
( ) - is first priority
[ ] - is like range of values you give to the character for which you have this [ ] tagged
|    - OR Symbol
{ } - number of times you wanted to see that charater for which you have { } tagged to
[-/_] - here the range of values that you give to the character are -, /, _.
so here
00/01/1900  --taking first valid option from given set
--
--
--
12_31_2099  -taking last valid option from given set

Sunday, April 6, 2014

VBscript to remove the string from a given text(ex: Path) and form a new path.

Sub split1()
 'Declaring the variables
Dim strString, strNewPath
strString = "c:\january\february\test.exe"

 'This helps to capture any error if gets created.
On Error Resume Next
strString = split(strString, "\")
 'Capture the Error message
If (Err.Number) Then
'MsgBox (Err.Description)
End If
 'UBound - Returns the highest available subscript for the indicated dimension of an array.
 'Navigating to each substring
For i = 0 To UBound(strString) - 1
  'Print the each substring
 MsgBox (strString(i))

strNewPath = strNewPath & strString(i) & "\"
  'MsgBox ("While breaking the string:" & strNewPath)
Next
 'MsgBox ("Without removing the string:" & strNewPath)
 'Since we have appended "\", trying to take Left part of the string with the length Len(strNewPath) -1
strNewPath = Left(strNewPath, Len(strNewPath) - 1)
'MsgBox ("After removing the string:" & strNewPath)
End Sub