Micro Focus QTP (UFT) Forums
VBA Code to read a substring - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: VBA Code to read a substring (/Thread-VBA-Code-to-read-a-substring)



VBA Code to read a substring - Dwarak Calayampundi - 09-07-2016

Hello All 

I am new to automation using UFT and new to programming as well. My question is around how to manipulate Substrings (a string within a string)
I want to find the position of a certain character in the string and find its start position and pass this start position to the mid function to capture the 
substring. The reason I need the position is because the position of the substring keeps moving. 

I also have it in a Do Loop Until 

Do
Window("Warehouse Management.ws").Type  micF5
Wait (2)
Window("Warehouse Management.ws").WinObject("Workstation ID:").Output CheckPoint("Workstation ID:_2")
L_Sline2 = DataTable.Value("G_Status_20",Global)
L_Status_20 = Instr(L_Sline2,"20 Print")
L_Status_20_Valid = mid(L_Sline2,L_Status_20,8)
Loop Until L_Status_20_Valid = "20 Print"

I keep getting the error "invalid procedure call or argument: 'mid'" The line with the error is underlined 

Could someone take a look at this one please......


RE: VBA Code to read a substring - Ankur - 09-07-2016

Please show an example of what you want exactly.


RE: VBA Code to read a substring - venkatesh9032 - 10-04-2016

Yes Please show an example..

Sample snipet -> hope you might be right track

strstring = "Unified"
strlen = Len(strstring)
Character = "f"

''Gets Length of the string
Msgbox strlen

CharacterPosition = Instr(1,strstring,Character)

''Gets Position of character
Msgbox CharacterPosition