alokranjan
New Member
- Joined
- Jan 2, 2023
- Messages
- 4
- Office Version
- 365
- Platform
- Windows
I want to fetch the data from a text file which starts with arrUserActivity in VBA. I'm able to fetch if there is no break line i.e Sample 1 but not for Sample 2.
Sample 1 : var arrUserActivity = [['9/13/2022 8:49:00 AM','MOA_S10EST','Firoj Aga','Remote Desktop using VNC 2.0 ','CBM'],['9/13/2022 1:54:00 PM','MOA_S10EST','Aux Tech2','Remote Desktop using VNC 2.0','Routine']];
Sample 2 : var arrUserActivity = [
['9/13/2022 8:49:00 AM','MOA_S10EST','Firoj Aga','Remote Desktop using VNC 2.0 ','CBM'], ['9/13/2022 1:54:00 PM','MOA_S10EST','Aux Tech2','Remote Desktop using VNC 2.0 ','Routine']];
My code is :
WhatToFind = "var arrUserActivity"
FromFile1 = Path + "\02-Text_Files\" + Site_Name + ".txt"
FileNum = FreeFile()
Open FromFile1 For Input As #FileNum
Do While Not EOF(FileNum)
lngCount = lngCount + 1 'increment a counter'
Line Input #FileNum, DataLine ' read in data 1 line at a time'
If InStr(1, DataLine, WhatToFind) > 0 Then 'the string is found'
bFound = True 'set a boolean value to true'
Exit Do 'and stop the loop'
End If
Loop
I'm able to fetch data if there is no line break.
Sample 1 : var arrUserActivity = [['9/13/2022 8:49:00 AM','MOA_S10EST','Firoj Aga','Remote Desktop using VNC 2.0 ','CBM'],['9/13/2022 1:54:00 PM','MOA_S10EST','Aux Tech2','Remote Desktop using VNC 2.0','Routine']];
Sample 2 : var arrUserActivity = [
['9/13/2022 8:49:00 AM','MOA_S10EST','Firoj Aga','Remote Desktop using VNC 2.0 ','CBM'], ['9/13/2022 1:54:00 PM','MOA_S10EST','Aux Tech2','Remote Desktop using VNC 2.0 ','Routine']];
My code is :
WhatToFind = "var arrUserActivity"
FromFile1 = Path + "\02-Text_Files\" + Site_Name + ".txt"
FileNum = FreeFile()
Open FromFile1 For Input As #FileNum
Do While Not EOF(FileNum)
lngCount = lngCount + 1 'increment a counter'
Line Input #FileNum, DataLine ' read in data 1 line at a time'
If InStr(1, DataLine, WhatToFind) > 0 Then 'the string is found'
bFound = True 'set a boolean value to true'
Exit Do 'and stop the loop'
End If
Loop
I'm able to fetch data if there is no line break.