Advertisement
Guest User

Untitled

a guest
May 7th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'http://www.sqaforums.com/forums/hp-unified-functional-testing-uft-mercury-quicktest-pro-qtp/153612-how-get-number-separately-string-vbscript.html
  2. '
  3. Function SplitNumAndText(strInput) 
  4.     Dim strNumbers, strLetters
  5.     strNumbers = "" : strLetters = ""
  6.    
  7.     For intChar = 1 To Len(strInput)
  8.         If IsNumeric(Mid(strInput, intChar, 1)) Then
  9.             strNumbers = strNumbers & Mid(strInput, intChar, 1)
  10.         Else
  11.             strLetters = strLetters & Mid(strInput, intChar, 1)
  12.         End If
  13.     Next
  14.     'SplitNumAndText = strNumbers & " and " & strLetters
  15.    SplitNumAndText = strNumbers
  16. End Function
  17.  
  18.  
  19. Set objFSO = CreateObject("Scripting.FileSystemObject")
  20. objStartFolder = "E:\test\testmap"
  21. Set objFolder = objFSO.GetFolder(objStartFolder)
  22. Set colFiles = objFolder.Files
  23.  
  24. max = "0"
  25. For Each objFile in colFiles
  26.     'Wscript.Echo objFile.Name
  27.    'msgbox SplitNumAndText(objFile.Name)
  28.    fileNumber = SplitNumAndText(objFile.Name)
  29.    
  30.     If fileNumber > max Then
  31.         'do whatever'
  32.        max = fileNumber
  33.     End If
  34.    
  35. Next
  36.  
  37. 'Max number
  38. msgbox max
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement