Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4083042
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:15:46+00:00 2026-05-20T18:15:46+00:00

I have a WPF project written in C#, and in order to get some

  • 0

I have a WPF project written in C#, and in order to get some information about an external dependency, I need to parse a VB6 script. The script’s location changes and its content changes some, but the main code I’m interested in will be of the format:

Select Case Fields("blah").Value
    Case "Some value"
        Fields("other blah").List = Lists("a list name")
    ...
End Select

I need to extract from this that when field ‘blah’ is set to ‘some value’, the list for field ‘other blah’ changes to list ‘a list name’. I tried Googling around for a VB6 parser written as a .NET library but haven’t found anything yet. At the risk of getting an answer like this one, should I just use regular expressions to find the code like this in the VB6 script, and extract the data I need? The code is found in a subroutine such that I can’t pass in ‘blah’, ‘some value’ and get back ‘other blah’, ‘a list name’. I have no control over the contents of this VB6 script.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T18:15:47+00:00Added an answer on May 20, 2026 at 6:15 pm

    You can parse it in a few steps. Please note the regex misses strings and comments, so use with care.

    First, we’ll use a helper class for the Fields("Target").List = Lists("Value") lines:

    class ListData
    {
        public string Target { get; set; }
        public string Value { get; set; }
    }
    

    Out patterns:

    string patternSelectCase = @"
    Select\s+Case\s+Fields\(""(?<CaseField>[\w\s]+)""\)\.Value
    (?<Cases>.*?)
    End\s+Select
    ";
    
    string patternCase = @"
    Case\s+""(?<Case>[\w\s]+)""\s+
    (?:Fields\(""(?<Target>[\w\s]+)""\)\.List\s*=\s*Lists\(""(?<Value>[\w\s]+)""\)\s+)*
    ";
    

    Next, we can try to parse the text in two passes (the code is a little ugly, by the way, but fairly basic):

    MatchCollection matches = Regex.Matches(vb, patternSelectCase,
            RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace | 
            RegexOptions.Singleline);
    
    Console.WriteLine(matches.Count);
    
    var data = new Dictionary<String, Dictionary<String, List<ListData>>>();
    foreach (Match match in matches)
    {
        var caseData = new Dictionary<String, List<ListData>>();
        string caseField = match.Groups["CaseField"].Value;
        string cases = match.Groups["Cases"].Value;
    
        MatchCollection casesMatches = Regex.Matches(cases, patternCase,
                 RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace | 
                 RegexOptions.Singleline);
        foreach (Match caseMatch in casesMatches)
        {
            string caseTitle = caseMatch.Groups["Case"].Value;
            var targetCaptures = caseMatch.Groups["Target"].Captures.Cast<Capture>();
            var valueCaptures = caseMatch.Groups["Value"].Captures.Cast<Capture>();
            caseData.Add(caseTitle, targetCaptures.Zip(valueCaptures, (t, v) =>
                new ListData
                {
                    Target = t.Value,
                    Value = v.Value
                }).ToList());
        }
    
        data.Add(caseField, caseData);
    }
    

    Now you have a dictionary with all data. For example:

    string s = data["foo"]["Some value2"].First().Value;
    

    Here’s a working example: https://gist.github.com/880148

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WPF project and I'm trying to setup a NAnt build script
I have a WPF application in VS 2008 with some web service references. For
I have a WPF window for editing database information, which is represented using an
Im trying to convert my WPF project to Silverlight. The WPF project was written
I have a WPF project (in .NET 4.0) with XAML resources embedded in as
I have an image of a fish in a WPF project (VB.net code behind),
I have a Visual Studio 2010 Entity Framework 4 WPF project and I'm not
I have WPF ListBox which is bound to a ObservableCollection, when the collection changes,
I have a WPF Window which has a among other controls hosts a Frame.
I have several wpf pages with update/delete/add buttons. I want to display to the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.