473,322 Members | 1,307 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

How to parse VBA code and generate XML file from it [Using C#]?

Hi all,

i have got a VBA code (a Subroutine in a module). Now what i want to do is that parse each line of this Subroutine (VBA code) and generate XML file from it using C#.

for example:

Option Compare Database
Dim RecordNumber As Integer
Dim TableName As String
Dim FLD As Field
Dim Db As Database, rs As Recordset
Dim TimeStart As Single, TimeEnd As Single, TimeElapsed As Single
Option Explicit

Sub ChangeAreaTD()
Set rs = Db.OpenRecordset(TableName, dbOpenTable)
Set FLD = rs![Field1]
TimeStart = Timer
.....

Sub End



This is my Subroutine code in a vba file

Now i'll be reading line by line from this file and parse the word and generate XML file from it.

Like
Expand|Select|Wrap|Line Numbers
  1.  String filename = "C:/.vba";
  2.                 using (StreamReader streader = new StreamReader(filename))
  3.                 {
  4.                     String line;
  5.                     while ((line = streader.ReadLine()) != null)
  6.                     {
  7.                         Processline(line);
  8.                         //Console.WriteLine(line);                    
  9.                     }
  10.                     streader.Close();
  11.                     Console.ReadLine();
  12.                 }
  13.             }
  14.             catch (Exception e)
  15.             {
  16.                 // Let the user know what went wrong.
  17.                 Console.WriteLine("The file could not be read:");
  18.                 Console.WriteLine(e.Message);
  19.             }         
  20.         }
  21.  
  22.         private static void Processline(string line)
  23.         {            
  24.             if(line.StartsWith("Sub"))
  25.             {
  26. //Lines of Code>
  27. }
  28. if(line.Contains("="))
  29.             {
  30. //Lines of Code
  31. }
  32. }
  33.  
I am doing like this. What should be there in Processline Method above. My question is how can i do this using C#?

Is there any other way to accomplish this, then please suggest.

How can i read lines from this Sub and Processeach line to generate an equivalent XML file of this VBA code using C#?

Any help would be highly appreciated.


Thanks

Mintoo
Jul 17 '10 #1
1 1935
ThatThatGuy
449 Expert 256MB
@prashantdixit
It would be difficult for you to analyze such code and judge as
where did the subroutine started ans when did it end..

Its as tough as building an language interpreter..
Jul 17 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Stuart Rogers | last post by:
My hosting service uses PHP 4.3.10 and when I run a php script which works perfectly on my local lan linux server on my hosting service I get this error:- Parse error: parse error, unexpected...
15
by: Swetha | last post by:
Hello I have a DropDownList that I am populating using the following SqlDataSource: <asp:DropDownList ID="parentIDDropDownList" runat="server" DataSourceID="SqlDataSource3"...
4
by: C | last post by:
Hi, I have a CSV file with some data (7,500 rows , 18 columns) How can I parse this file in C#? Can I programmatically save the file as an Excel Workbook and then parse the file using the...
6
by: Lenny Wintfeld | last post by:
Hi I'm attempting additions/changes to a Java program that (among other things) uses XSLT to transform a large (96 Mb) XML file. It runs fine on small XML files but generates OutOfMemory...
5
by: moddster | last post by:
Hi Guys. I am a newbie to perl and need some help with a problem. PROBLEM: I have to parse an HTML file and get rid of all the HTML tags and count the number of sumbissions a person has through...
4
by: Pranjal9880 | last post by:
Hi all I am trying to parse the xml file using perl in which I am succeeded , I am able to fetch the data from the xml file by using one keyword. Now I want to do it using more than one keyword. It...
1
by: dli | last post by:
Hello, I am new to this community, and hope that you will be able to help me out with this. I am trying to load a .csporj file with: my $myXML = XML::Smart->new( $BuildFile,...
1
by: psawant311 | last post by:
Hello All, i am going to parse a sportsml file. Can any one help me for how to parse a sportsml file in php ?. Or give any reference code?.
0
by: tochins | last post by:
Hello, I have a code with which I can parse a file of around 1MB. However I am looking to parse an xml file of about 128MB. Below is my code Dim xml_doc As New DOMDocument Dim brtn As...
0
by: faros | last post by:
i want to code generate for xml simple file i have theses lines in XML: <?xml version="1.0" encoding="utf-8" ?> <Elements xmlns="..."> <Field ID="{F094C1EA-786A-4c5b-BFBC-58A63863A3DF}" ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.