awyeah
09-08-2009, 01:36 PM
Dear all,
This is a tricky situation. I want to extract a certain substring from the strings given below, using VB 6.0.
I process each string (row) in a for loop one by one.
13-08-2008,10:30:00,30,13-08-2008,10:29:00,No Consumption,13-08-2008,10:29:00,Voltage Cut,-,13-08-2008,10:33:00,AC Power Down,-,13-08-2008,10:35:00,AC Power Down,-
13-08-2008,11:00:00,20,13-08-2008,11:14:00,Voltage Cut,-,13-08-2008,11:14:00,AC Power Down,-
13-08-2008,11:30:00,20,13-08-2008,11:30:00,AC Power Down,-
04-08-2008,19:00:00,527,04-08-2008,18:47:00,AC Power Down,-
25-08-2008,18:30:00,254,25-08-2008,18:25:00,AC Power Down,-
25-08-2008,19:00:00,0,25-08-2008,19:09:00,Current Reversal,25-08-2008,19:12:00,AC Power Down,-
27-08-2008,12:00:00,560,27-08-2008,11:59:00,AC Power Down,-,27-08-2008,11:59:00,Voltage Cut,-
27-08-2008,15:00:00,0,27-08-2008,15:12:00,Voltage Cut,-
27-08-2008,16:30:00,350,27-08-2008,16:17:00,Meter Opened,27-08-2008,16:20:00,Voltage Cut,-
28-08-2008,06:30:00,30,28-08-2008,06:16:00,Voltage Cut,-
28-08-2008,15:00:00,320,28-08-2008,14:46:00,Zero Tolerance,28-08-2008,14:47:00,AC Power Down,-,28-08-2008,14:49:00,Voltage Cut,-
28-08-2008,17:30:00,10,28-08-2008,17:19:00,Voltage Cut,-
29-08-2008,00:30:00,100,29-08-2008,00:36:00,No Consumption,29-08-2008,00:38:00,Voltage Cut,-,29-08-2008,00:39:00,AC Power Down,-
29-08-2008,01:00:00,80,29-08-2008,01:00:00,AC Power Down,-
I am checking for two major events.
1. Voltage Cut
2. Ac Power Down
In each string I want find the first occurence of a "Voltage Cut" or "AC Power Down" event (whichever comes first).
After finding the first occurence in the string, I want to extract the "time" when a Voltage Cut or Ac Power Down event occurs.
As you can see in each of the strings above, before a Voltage Cut or Ac Power Down event happens, the most previous data before them is the "time" > Want to extract this value.
So for my data above, I should have something like this:
10:29:00
11:14:00
11:30:00
18:47:00
18:25:00
19:12:00
11:59:00
15:12:00
16:20:00
06:16:00
14:47:00
17:19:00
00:38:00
01:00:00
This has become tricky, due to the inclusion of other non-important events such as, "No consumption", "Meter Opened", "Zero Tolerance" and etc, which I want to ignore.
All help is appreciated.
This is a tricky situation. I want to extract a certain substring from the strings given below, using VB 6.0.
I process each string (row) in a for loop one by one.
13-08-2008,10:30:00,30,13-08-2008,10:29:00,No Consumption,13-08-2008,10:29:00,Voltage Cut,-,13-08-2008,10:33:00,AC Power Down,-,13-08-2008,10:35:00,AC Power Down,-
13-08-2008,11:00:00,20,13-08-2008,11:14:00,Voltage Cut,-,13-08-2008,11:14:00,AC Power Down,-
13-08-2008,11:30:00,20,13-08-2008,11:30:00,AC Power Down,-
04-08-2008,19:00:00,527,04-08-2008,18:47:00,AC Power Down,-
25-08-2008,18:30:00,254,25-08-2008,18:25:00,AC Power Down,-
25-08-2008,19:00:00,0,25-08-2008,19:09:00,Current Reversal,25-08-2008,19:12:00,AC Power Down,-
27-08-2008,12:00:00,560,27-08-2008,11:59:00,AC Power Down,-,27-08-2008,11:59:00,Voltage Cut,-
27-08-2008,15:00:00,0,27-08-2008,15:12:00,Voltage Cut,-
27-08-2008,16:30:00,350,27-08-2008,16:17:00,Meter Opened,27-08-2008,16:20:00,Voltage Cut,-
28-08-2008,06:30:00,30,28-08-2008,06:16:00,Voltage Cut,-
28-08-2008,15:00:00,320,28-08-2008,14:46:00,Zero Tolerance,28-08-2008,14:47:00,AC Power Down,-,28-08-2008,14:49:00,Voltage Cut,-
28-08-2008,17:30:00,10,28-08-2008,17:19:00,Voltage Cut,-
29-08-2008,00:30:00,100,29-08-2008,00:36:00,No Consumption,29-08-2008,00:38:00,Voltage Cut,-,29-08-2008,00:39:00,AC Power Down,-
29-08-2008,01:00:00,80,29-08-2008,01:00:00,AC Power Down,-
I am checking for two major events.
1. Voltage Cut
2. Ac Power Down
In each string I want find the first occurence of a "Voltage Cut" or "AC Power Down" event (whichever comes first).
After finding the first occurence in the string, I want to extract the "time" when a Voltage Cut or Ac Power Down event occurs.
As you can see in each of the strings above, before a Voltage Cut or Ac Power Down event happens, the most previous data before them is the "time" > Want to extract this value.
So for my data above, I should have something like this:
10:29:00
11:14:00
11:30:00
18:47:00
18:25:00
19:12:00
11:59:00
15:12:00
16:20:00
06:16:00
14:47:00
17:19:00
00:38:00
01:00:00
This has become tricky, due to the inclusion of other non-important events such as, "No consumption", "Meter Opened", "Zero Tolerance" and etc, which I want to ignore.
All help is appreciated.