DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Extract certain substring from string in VB 6.0

  1. #1
    Join Date
    Apr 2008
    Posts
    13

    Extract certain substring from string in VB 6.0

    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.

  2. #2
    Join Date
    Jun 2009
    Posts
    135
    Look the the following in help...

    Left Function
    Right Function
    Mid Function
    Trim Function
    Replace Function
    Split Function
    Join Function



    Good Luck

Similar Threads

  1. Initialise Date type Variable in VB6
    By Lennie in forum VB Classic
    Replies: 9
    Last Post: 11-09-2008, 09:19 PM
  2. Input string was not in a correct format
    By mdengler in forum ASP.NET
    Replies: 0
    Last Post: 11-26-2002, 03:32 PM
  3. Replies: 1
    Last Post: 06-05-2001, 06:12 AM
  4. Replies: 0
    Last Post: 06-22-2000, 07:30 AM
  5. Trying to print a PDF File from VB
    By Kunal Sharma in forum VB Classic
    Replies: 2
    Last Post: 04-25-2000, 03:45 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center