Results 1 to 8 of 8

Thread: help parsing a string

  1. #1

    Thread Starter
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,762

    help parsing a string

    I have this text file that I need to parse the number the is bolded

    Code:
    File creation date:  9/14/2005
    File creation time:  8:57:33 AM
    
    Product: MyApp
    Version: 1.0.2083.13856
    Build Date: 9/14/2005 8:46:05 AM
    
    
    IP Address: 
    XXX.XXX.X.XXX
    
    System Information:
    	Computer Name = KEVIN-LT
    	Computer Manufacturer = Hewlett-Packard 
    	Computer Model = Pavilion zv5000 (PL976UA#ABA) 
    	OS Name = Microsoft Windows XP Professional|C:\WINDOWS|\Device\Harddisk0\Partition1
    	OS Version = 5.1.2600
    	System Type = X86-based PC
    	Total Physical Memory = 401584128
    	Windows Directory = C:\WINDOWS
    Drive Information
    	C:\	Volume Number: -666002322
    	D:\	Volume Number: -1062776663
    	E:\	Volume Number: -265637814
    	G:\	Volume Number: -265637814
    	J:\	Volume Number: -1070353568
    
    Current number of systems: 1
    the file will always have "C:\ Volume Number:" appearing only once right before the number I need. Can I split a string based on another string? or what functions can I use that will lead to an efficient way to do this? I don't need the code I can write that if I know the best functions to use to get the job done.
    thanks
    kevin
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: help parsing a string

    Probably Regular Expressions will be the best. I have only used it twice and it seems to be very flexiable in what it can do.
    Is your app outputting the file?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,762

    Re: help parsing a string

    Quote Originally Posted by RobDog888
    Probably Regular Expressions will be the best. I have only used it twice and it seems to be very flexiable in what it can do.
    Is your app outputting the file?
    Yeah it is, then another app I'm writting parses it.
    I'll look at regular expression and see how to use it (them)
    thanks
    kevin
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: help parsing a string

    since your app writes the file then wouldnt it be easier to write it out in a easier format for you to read in? or maybe another file
    for parsing only and not the user?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5

    Thread Starter
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,762

    Re: help parsing a string

    yeah it would be, but the format is already in use by others and would be a terrible pain to change everything else. You know, it's the boring details...it always comes down to details.
    kevin
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: help parsing a string

    I thought about that too, but if you were to write out a duplicate file customized to your parsing needs then that will possibly
    save you some headaches.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7

    Thread Starter
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,762

    Re: help parsing a string

    Quote Originally Posted by RobDog888
    I thought about that too, but if you were to write out a duplicate file customized to your parsing needs then that will possibly
    save you some headaches.
    unfortunatley that create other headaches

    I have it working using instr like this (with a small output file mod)
    VB Code:
    1. 's= OutputFile.txt
    2.                 Const rConst As String = "C:\ Volume Number:"
    3.                 Dim iStart As Integer = InStr(s, rConst)
    4.  
    5.                 istart += rConst.Length
    6.                 Dim iEnd As Integer = s.IndexOf(vbCrLf, iStart)
    7.                 Dim myNum As String = s.Substring(iStart, iEnd - iStart).Trim
    but I would rather use a RegEx but this doesn't work
    VB Code:
    1. Const rConst As String = "C:\ Volume Number:"
    2.                 Dim r As New System.Text.RegularExpressions.Regex(rConst)
    3.                 Dim iStart As Integer = r.Match(s).Index
    iStart is always 0. How come? I suspect I'm not using RegEX correctly

    thanks
    for the help Rob
    kevin
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

  8. #8
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: help parsing a string

    There are codes that make up your search string. It looks like 1337.

    Look here, I think this will here for the expression needed.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width