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
- String filename = "C:/.vba";
- using (StreamReader streader = new StreamReader(filename))
- {
- String line;
- while ((line = streader.ReadLine()) != null)
- {
- Processline(line);
- //Console.WriteLine(line);
- }
- streader.Close();
- Console.ReadLine();
- }
- }
- catch (Exception e)
- {
- // Let the user know what went wrong.
- Console.WriteLine("The file could not be read:");
- Console.WriteLine(e.Message);
- }
- }
- private static void Processline(string line)
- {
- if(line.StartsWith("Sub"))
- {
- //Lines of Code>
- }
- if(line.Contains("="))
- {
- //Lines of Code
- }
- }
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