|
This doesn't work at all.....
@!$(-)@ $@r£r@Z
|
|
|
|
|
Please remove this article as many people found that it's not working and even i tried to convert VB.Net code of 1100 lines but it's not working !!!
sdf
|
|
|
|
|
Read the introduction you gimboid: “GBVB (Goodbye VB) is an amazing tool that flawlessly converts any portion of VB.NET code to C# code in a fraction of seconds.” I would love to be able to say this. If you are looking for such a tool, forget about it. You will not be able to find it, and I will explain why later in this article.
|
|
|
|
|
For e.g. you have a With block in VB.Net, this executable doesn't convert at all.
VB.Net code:
Function AddStateList() as ArrayList
Dim MyList as ArrayList
'Begin here to add -
With MyList
.Add("AL")
.Add("DE")
.Add("NE")
.Add("MA")
.Add("MN")
.Add("MO")
.Add("CA")
.Add("KS")
.Add("WI")
.Add("WA")
End With 'end here add
Return MyList
End Function
With this all I get is this C# code:
{
as AddStateList()
{
ArrayList;
as MyList;
ArrayList;
// Begin here to add -
With;
MyList;
}
}
Lotus
|
|
|
|
|
High claims for an extremely foolish tool
FireFox Rocks !
www.getfirefox.com
|
|
|
|
|
zecougar wrote: High claims for an extremely foolish tool
What high claims?
Read the introduction!
“GBVB (Goodbye VB) is an amazing tool that flawlessly converts any portion of VB.NET code to C# code in a fraction of seconds.” I would love to be able to say this. If you are looking for such a tool, forget about it. You will not be able to find it, and I will explain why later in this article.
It looks like he is claiming that it won't work. So, what are you complaining about? You were told in advance it wasn't going to work!
|
|
|
|
|
Hi, thought I'd chime in by observing that the first sentence would be a LOT clearer, if standard double-quotation characters were used, and the sentence after it were bolded .. as in the reply above. On my PC, the quotes around the first sentence turn into almost invisible rectangles. And nothing gets bolded.
It is important for any author to understand that what seems perfectly clear to them often isn't obvious to the average reader. Most of the time, people "skim" rather than "read".
I had to do a double-take myself, and carefully read the whole paragraph to realize the author wasn't actually making that claim...
|
|
|
|
|
it's not so convinient
coz we need to build the source code to dll
but at least it works
|
|
|
|
|
I pasted my b.net code which is like 500 lines and there comes my c# code which is 2 lines
class xxx
end class
hahaha !!
adi.mr
|
|
|
|
|
Not only does this not work, its not even close to working, yes I agree its not an easy thing to do but this must be the most pathetic attempt at any problem ive ever seen. I tried a variety of conversions and none were even close to the proper syntax.
Dont waste your time downloading this!
|
|
|
|
|
Hi to All,
How can i find out the server IP Address? if any body know plzz tel me with code....
thanks
Honey
|
|
|
|
|
Hello Daniel
I was inspired by your manner of writing - with humor and very clear but unfortunately GBVB tool that I compiled from source does not work well. For long VB.NET source I got only one small method body. Maybe this is because I am using .NET 2.0? Hope this will be fixed at some point.
Thank you
Martin Rakhmanov
http://jimmers.russia.webmatrixhosting.net/
|
|
|
|
|
|
i try convert code and dont work, fail in the 4 line in intruccion "sub foo()".
|
|
|
|
|
Read the introduction you goit!
“GBVB (Goodbye VB) is an amazing tool that flawlessly converts any portion of VB.NET code to C# code in a fraction of seconds.” I would love to be able to say this. If you are looking for such a tool, forget about it. You will not be able to find it, and I will explain why later in this article.
|
|
|
|
|
A simple conversion of:
Public Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hKey As Integer, ByVal lpSubKey As String, ByVal ulOptions As Integer, ByVal samDesired As Integer, ByRef phkResult As Integer) As Integer
Not only is incomplete... it is totally unusable to even convert that line of code from VB.Net to C#.Net!
|
|
|
|
|
For both code samples in your article gbvb.exe produces
{
}
LOL???
|
|
|
|
|
Rather than starting to such a cool project from converting c# to Vb; I think conversion from c# to Vb would be much more easier and cooler. The one to know c# has of nothing to the with Vb whereas it is not so for those who deal in Vb. And there would not be any defining problems. As vb tolerates giving numeric and string value without convertion, How can u hope to verify which she or he has choosen. But in c# to vb conversion You know what to convert and convert to what.TAKE iT EASY. indeed for along time I am dealing with those too.
|
|
|
|
|
Tried it with the following code and it bombed:
Imports System.Data
Imports Office = Microsoft.Office.Core
Imports Excel = Microsoft.Office.Interop.Excel
Public MustInherit Class WorksheetBase
Protected Const CHART_BORDER_LINE_STYLE As Integer = 0
Protected Const CHART_WALL_FORECOLOR As Integer = 37
Protected Const CHART_WALL_BACKCOLOR As Integer = 2
Protected Const BARCHART_SERIES_COLOR As Integer = 46
Protected Const BARCHART_SHOW_ALL_TICK_LABELS As Integer = 1
' Number of data rows
Protected myRowCount As Integer
' Are we in the processing of populating the display - disables on worksheet change handling
Protected myIsDisplaying As Boolean
' Currently selected range
Protected myActiveRange As Excel.Range
Protected WithEvents myWorksheet As Excel.Worksheet
' Range spans all display columns on the worksheet
Protected columnSpanRange As Excel.Range
Protected Sub New(ByVal worksheetName As String)
myWorksheet = Globals.ExcelApplication.Worksheets.Item(worksheetName)
If myWorksheet Is Nothing Then
Throw New ApplicationException("Worksheet name not found: " & worksheetName)
End If
End Sub
' Create a single range spanning all column ranges
Protected Sub SetColumnSpanRange(ByVal rangeList As Excel.Range())
Select Case rangeList.Length
Case 0
Throw New ApplicationException("Error creating spanRange - no columns specified")
Case 1
columnSpanRange = rangeList(0)
Case Else
columnSpanRange = Globals.ExcelApplication.Union(rangeList(0), rangeList(1))
For i As Integer = 2 To rangeList.Length - 1
columnSpanRange = Globals.ExcelApplication.Union(columnSpanRange, rangeList(i))
Next
End Select
End Sub
' Number of data rows containing data
Public Property RowCount() As Integer
Get
Return myRowCount
End Get
Set(ByVal value As Integer)
myRowCount = value
End Set
End Property
' First column of report area.
Public ReadOnly Property FirstColumn() As Integer
Get
Return columnSpanRange.Column
End Get
End Property
' Last column of report area.
Public ReadOnly Property LastColumn() As Integer
Get
Return FirstColumn + columnSpanRange.Count - 1
End Get
End Property
' First row of report area
Public ReadOnly Property FirstRow() As Integer
Get
Return columnSpanRange.Row
End Get
End Property
' Last row of report area
Public ReadOnly Property LastRow() As Integer
Get
Return FirstRow + RowCount - 1
End Get
End Property
' Are we in the processing of populating the display
Public Property IsDisplaying() As Boolean
Get
Return myIsDisplaying
End Get
Set(ByVal value As Boolean)
myIsDisplaying = value
End Set
End Property
' Currently selected range
Public ReadOnly Property ActiveRange() As Excel.Range
Get
Return myActiveRange
End Get
End Property
' Worksheet managed by the specific worksheet class
Public ReadOnly Property ExcelWorksheet() As Excel.Worksheet
Get
Return myWorksheet
End Get
End Property
' Activate the current sheet insuring that it is visible and that grid lines are not displayed
Public Sub ActivateSheet()
ExcelWorksheet.Visible = Excel.XlSheetVisibility.xlSheetVisible
ExcelWorksheet.Activate()
Globals.ExcelApplication.ActiveWindow.DisplayGridlines = False
End Sub
' Create a range over the cell specified by the column and row values on the specified worksheet
Public Function CreateRange(ByVal ws As Excel.Worksheet, ByVal column As String, ByVal row As Integer) As Excel.Range
Dim rangeString As String = column & row.ToString()
Return ws.Range(rangeString)
End Function
' Create a range over the cell specified by the column and row values on this worksheet
Public Function CreateRange(ByVal column As String, ByVal row As Integer) As Excel.Range
Return CreateRange(ExcelWorksheet, column, row)
End Function
' Create a range using two columns specified as integers spanning several rows.
' Must convert the range from R1C1 format to A1 format to create range instance
Public Function CreateRange(ByVal startColumn As Integer, ByVal startRow As Integer, _
ByVal endColumn As Integer, ByVal endRow As Integer) As Excel.Range
Dim rangeR1C1 As String = String.Format("R{0}C{1}:R{2}C{3}", startRow, startColumn, endRow, endColumn)
Dim rangeA1 As String = Globals.ExcelApplication.ConvertFormula(rangeR1C1, Excel.XlReferenceStyle.xlR1C1, Excel.XlReferenceStyle.xlA1)
Return ExcelWorksheet.Range(rangeA1)
End Function
' Create a range using a single column specified as an integer spanning several rows.
' Must convert the range from R1C1 format to A1 format to create range instance
Public Function CreateRange(ByVal column As Integer, ByVal startRow As Integer, ByVal endRow As Integer) As Excel.Range
Dim rangeR1C1 As String = String.Format("R{0}C{1}:R{2}C{1}", startRow, column, endRow)
Dim rangeA1 As String = Globals.ExcelApplication.ConvertFormula(rangeR1C1, Excel.XlReferenceStyle.xlR1C1, Excel.XlReferenceStyle.xlA1)
Return ExcelWorksheet.Range(rangeA1)
End Function
' Create a range using a single column specified as an integer and a single rows.
' Must convert the range from R1C1 format to A1 format to create range instance
Public Function CreateRange(ByVal column As Integer, ByVal row As Integer) As Excel.Range
Dim rangeR1C1 As String = String.Format("R{0}C{1}", row, column)
Dim rangeA1 As String = Globals.ExcelApplication.ConvertFormula(rangeR1C1, Excel.XlReferenceStyle.xlR1C1, Excel.XlReferenceStyle.xlA1)
Return ExcelWorksheet.Range(rangeA1)
End Function
' Create a named range over a single column / row with the column specified as a string
Public Function CreateNamedRange(ByVal rangeName As String, ByVal column As String, ByVal row As Integer) As Excel.Range
Dim rangeFormula As String = "=" & column & row
Return CreateNamedRange(rangeName, rangeFormula)
End Function
' Create a named range over the specified cells
' Prepends required "=" if not included
Public Function CreateNamedRange(ByVal rangeName As String, ByVal rangeFormula As String) As Excel.Range
' If range formula does not begin with the required "=" then add it.
Dim tempRangeFormula As String
tempRangeFormula = IIf(rangeFormula.StartsWith("="), rangeFormula, "=" & rangeFormula)
' Create the named range and return a reference
Dim tempName As Excel.Name = ExcelWorksheet.Names.Add(rangeName, tempRangeFormula)
Return ExcelWorksheet.Range(rangeName)
End Function
' Handle SelectionChange event
' Store selected range in myActiveRange making it available to the ActiveRange property
Protected Sub Worksheet_SelectionChange(ByVal target As Excel.Range) Handles myWorksheet.SelectionChange
myActiveRange = target
DoWorksheetSelectionChangeWork(target)
End Sub
' Give derived class an opportunity to do additional work
Protected Overridable Sub DoWorksheetSelectionChangeWork(ByVal target As Excel.Range)
' Default is to do nothing extra
End Sub
' Sets the formula in the English (United States) locale. This enables code that executes
' correctly in different locales. For example, formula "=SUM (1.5, 3.0)"
' is correct in English (United States), but would fail in French (France),
' which would expect "=SOMME(1,5;3,0)". We cannot automatically translate formulas;
' instead, we are using reflection to specify the En-US locale.
Public Shared Sub SetFormula(ByVal range As Excel.Range, ByVal formula As String)
' en-US culture info used to set locale independent formulas
Dim enUSCulture As New System.Globalization.CultureInfo(1033)
' Type descripter for Excel.Range - allows us to set the Formula property using reflection
Dim rangeType As Type = GetType(Excel.Range)
' Set the range's Formula property indicating that the formula being assigned is formatted as en-US culture
' Runtime will automatically translate the formula to the actual culture
rangeType.InvokeMember("Formula", _
System.Reflection.BindingFlags.Public Or System.Reflection.BindingFlags.Instance Or System.Reflection.BindingFlags.SetProperty, _
Nothing, _
range, _
New Object() {formula}, _
enUSCulture)
End Sub
' Each worksheet provides their own implementation as determining the selected symbol is different for each
' This method is called when initiating a new Stock Allocation while anther sheet is active. If the sheet returns a
' non-empty string, the Stock Allocation sheet will automatically select the corresponding symbol
Public Overridable Function GetActiveStockSymbol() As String
Return String.Empty
End Function
' The workshet specific mechanism for redrawing the worksheet contents
' Used primarily when some event has changed the contents of the DataSet such as a price update
' or an applied allocation.
Public MustOverride Sub Refresh()
' Format the borders around the data
Protected Sub FormatDataBorders(ByVal displayHorizontal As Boolean)
' Create range over data area
' Dim rangeString As String = String.Format("{0}{1}:{2}{3}", startingColumn, startingRow, endingColumn, myEndingRow)
Dim rng As Excel.Range = CreateRange(FirstColumn, FirstRow, LastColumn, LastRow)
' Format horozontal borders within the range
If RowCount > 1 Then
With rng.Borders(Excel.XlBordersIndex.xlInsideHorizontal)
If displayHorizontal Then
.LineStyle = Excel.XlLineStyle.xlContinuous
.Weight = Excel.XlBorderWeight.xlThin
.ColorIndex = Excel.XlColorIndex.xlColorIndexAutomatic
Else
.LineStyle = Excel.XlLineStyle.xlLineStyleNone
End If
End With
' Format vertical borders within the range
With rng.Borders(Excel.XlBordersIndex.xlInsideVertical)
.LineStyle = Excel.XlLineStyle.xlContinuous
.Weight = Excel.XlBorderWeight.xlThin
.ColorIndex = Excel.XlColorIndex.xlColorIndexAutomatic
End With
End If
' Format bottom border
With rng.Borders(Excel.XlBordersIndex.xlEdgeBottom)
.LineStyle = Excel.XlLineStyle.xlContinuous
.Weight = Excel.XlBorderWeight.xlMedium
.ColorIndex = Excel.XlColorIndex.xlColorIndexAutomatic
End With
' Format left border
With rng.Borders(Excel.XlBordersIndex.xlEdgeLeft)
.LineStyle = Excel.XlLineStyle.xlContinuous
.Weight = Excel.XlBorderWeight.xlMedium
.ColorIndex = Excel.XlColorIndex.xlColorIndexAutomatic
End With
' Format right border
With rng.Borders(Excel.XlBordersIndex.xlEdgeRight)
.LineStyle = Excel.XlLineStyle.xlContinuous
.Weight = Excel.XlBorderWeight.xlMedium
.ColorIndex = Excel.XlColorIndex.xlColorIndexAutomatic
End With
' Format top border
With rng.Borders(Excel.XlBordersIndex.xlEdgeTop)
.LineStyle = Excel.XlLineStyle.xlContinuous
.Weight = Excel.XlBorderWeight.xlMedium
.ColorIndex = Excel.XlColorIndex.xlColorIndexAutomatic
End With
End Sub
' Removes the contents of all cells within the specified range
' Function is used primarily to delete the existing data contents of a sheet so that it can
' be repopulated.
Protected Sub ClearContents()
' Protected Sub ClearContents(ByVal startingRow As Integer, ByVal startingColumn As String, ByVal endingColumn As String, ByVal resetBorders As Boolean)
If RowCount > 0 Then
' Create range over data rows
Dim rng As Excel.Range = CreateRange(FirstColumn, FirstRow, LastColumn, LastRow)
' Remove data from all cells in range
rng.ClearContents()
' Delete all rows except the first so as to not lose cell formatting
If RowCount > 1 Then
rng = CreateRange(FirstColumn, FirstRow + 1, LastColumn, LastRow)
'rng.Select()
'Globals.ExcelApplication.Selection.Delete(Excel.XlDirection.xlUp)
rng.Delete(Excel.XlDirection.xlUp)
End If
' Delete all charts
ExcelWorksheet.ChartObjects.Delete()
' Reset row count
RowCount = 0
End If
End Sub
' Converts the chart name returned from the ActiveChart.Name property to the format
' expected by the ActiveSheet members such as ActiveSheet.DrawingObjects and
' ActiveSheet.Shapes. The ActiveChart.Name property returns the name with the
' containing sheet name prepended (ex: "Account Summary Chart 1") but the ActiveSheet
' members do not expect the sheet name to be prepended (ex: "Chart 1") so this function
' strips the name down to the non-sheet-name portion
Public Function GetActiveChartName() As String
Dim chartName As String = Globals.ExcelApplication.ActiveChart.Name
Return chartName.Substring(chartName.IndexOf("Chart"))
End Function
' Details of creating chart members
Public Function CreateChart(ByVal sheetName As String, ByVal chartType As Excel.XlChartType, ByVal rng As Excel.Range, ByVal title As String, ByVal foreColor As Integer, ByVal backColor As Integer, ByVal top As Integer, ByVal left As Integer, ByVal height As Integer, ByVal width As Integer) As Excel.Shape
Dim excelChart As Excel.Chart = Globals.ExcelApplication.Charts.Add()
excelChart.ChartType = chartType
excelChart.SetSourceData(rng, Excel.XlRowCol.xlColumns)
excelChart.HasTitle = True
excelChart.ChartTitle.Text = title
excelChart.HasLegend = False
If chartType = Excel.XlChartType.xl3DPieExploded Then
excelChart.ApplyDataLabels(Excel.XlDataLabelsType.xlDataLabelsShowLabel)
excelChart.PlotArea.Interior.ColorIndex = Excel.XlColorIndex.xlColorIndexNone
excelChart.PlotArea.Border.LineStyle = Excel.XlLineStyle.xlLineStyleNone
End If
excelChart.Location(Excel.XlChartLocation.xlLocationAsObject, sheetName)
Globals.ExcelApplication.Selection.Border.LineStyle = CHART_BORDER_LINE_STYLE
FillSelectionWithGradient(Office.MsoGradientStyle.msoGradientDiagonalUp, foreColor, backColor)
Globals.ExcelApplication.ActiveSheet.DrawingObjects(GetActiveChartName()).Shadow = True
If chartType = Excel.XlChartType.xl3DBarClustered Then
Globals.ExcelApplication.ActiveChart.Walls.Select()
FillSelectionWithGradient(Office.MsoGradientStyle.msoGradientHorizontal, CHART_WALL_FORECOLOR, CHART_WALL_BACKCOLOR)
Globals.ExcelApplication.ActiveChart.SeriesCollection(1).Select()
Globals.ExcelApplication.Selection.Interior.ColorIndex = BARCHART_SERIES_COLOR
Globals.ExcelApplication.ActiveChart.Axes(Excel.XlAxisType.xlCategory).TickLabelSpacing = BARCHART_SHOW_ALL_TICK_LABELS
End If
Dim excelShape As Excel.Shape = Globals.ExcelApplication.ActiveSheet.Shapes(GetActiveChartName())
excelShape.Top = top
excelShape.Left = left
excelShape.Height = height
excelShape.Width = width
SetActiveChartFonts()
Return excelShape
End Function
' Create range for charts using the ranges specifying the lable and value columns
' Charts are a special case as they actually span two sets of columns
Public Function CreateChartRange(ByVal label As Excel.Range, ByVal value As Excel.Range) As Excel.Range
Dim rangeR1C1 As String = String.Format("R{0}C{1}:R{2}C{1},R{3}C{4}:R{5}C{4}", label.Row, _
label.Column, label.Row + RowCount - 1, value.Row, value.Column, value.Row + RowCount - 1)
Dim rangeA1 As String = Globals.ExcelApplication.ConvertFormula(rangeR1C1, Excel.XlReferenceStyle.xlR1C1, _
Excel.XlReferenceStyle.xlA1)
Return ExcelWorksheet.Range(rangeA1)
End Function
' Handles details of setting the current selection to a compound color gradient
Protected Sub FillSelectionWithGradient(ByVal gradientStyle As Office.MsoGradientStyle, ByVal foreColor As Integer, ByVal backColor As Integer)
With Globals.ExcelApplication.Selection.Fill
.TwoColorGradient(gradientStyle, 1)
.Visible = True
.ForeColor.SchemeColor = foreColor
.BackColor.SchemeColor = backColor
End With
End Sub
' Setup chart fonts
Protected Sub SetActiveChartFonts()
With Globals.ExcelApplication.ActiveChart.ChartTitle.Font
.Name = "Arial"
.FontStyle = "Bold"
.Size = 11
End With
If Globals.ExcelApplication.ActiveChart.ChartType = Excel.XlChartType.xl3DBarClustered Then
If Globals.ExcelApplication.ActiveChart.HasAxis(Excel.XlAxisType.xlCategory) Then
Globals.ExcelApplication.ActiveChart.Axes(Excel.XlAxisType.xlCategory).Select()
Globals.ExcelApplication.Selection.TickLabels.AutoScaleFont = False
With Globals.ExcelApplication.Selection.TickLabels.Font
.Name = "Arial"
.FontStyle = "Bold"
.Size = 8
End With
End If
If Globals.ExcelApplication.ActiveChart.HasAxis(Excel.XlAxisType.xlValue) Then
Globals.ExcelApplication.ActiveChart.Axes(Excel.XlAxisType.xlValue).Select()
Globals.ExcelApplication.Selection.TickLabels.AutoScaleFont = False
With Globals.ExcelApplication.Selection.TickLabels.Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 8
End With
End If
ElseIf Globals.ExcelApplication.ActiveChart.ChartType = Excel.XlChartType.xl3DPieExploded Then
Globals.ExcelApplication.ActiveChart.SeriesCollection(1).DataLabels.Select()
Globals.ExcelApplication.Selection.AutoScaleFont = False
With Globals.ExcelApplication.Selection.Font
.Name = "Arial"
.FontStyle = "Bold"
.Size = 8
End With
End If
End Sub
End Class
CD
|
|
|
|
|
Our Instant C# VB.NET to C# converter produces the following:
using System.Data;
using Office = Microsoft.Office.Core;
using Excel = Microsoft.Office.Interop.Excel;
public abstract class WorksheetBase
{
protected const int CHART_BORDER_LINE_STYLE = 0;
protected const int CHART_WALL_FORECOLOR = 37;
protected const int CHART_WALL_BACKCOLOR = 2;
protected const int BARCHART_SERIES_COLOR = 46;
protected const int BARCHART_SHOW_ALL_TICK_LABELS = 1;
// Number of data rows
protected int myRowCount;
// Are we in the processing of populating the display - disables on worksheet change handling
protected bool myIsDisplaying;
// Currently selected range
protected Excel.Range myActiveRange;
protected Excel.Worksheet myWorksheet;
// Range spans all display columns on the worksheet
protected Excel.Range columnSpanRange;
//TODO: INSTANT C# TODO TASK: Insert the following converted event handlers at the end of the 'InitializeComponent' method for forms or into a constructor for other classes:
myWorksheet.SelectionChange += new System.EventHandler(Worksheet_SelectionChange);
protected WorksheetBase(string worksheetName)
{
myWorksheet = Globals.ExcelApplication.Worksheets[worksheetName];
if (myWorksheet == null)
{
throw new ApplicationException("Worksheet name not found: " + worksheetName);
}
}
// Create a single range spanning all column ranges
protected void SetColumnSpanRange(Excel.Range[] rangeList)
{
switch (rangeList.Length)
{
case 0:
throw new ApplicationException("Error creating spanRange - no columns specified");
break;
case 1:
columnSpanRange = rangeList[0];
break;
default:
columnSpanRange = Globals.ExcelApplication.Union(rangeList[0], rangeList[1]);
//INSTANT C# NOTE: The ending condition of VB 'For' loops is tested only on entry to the loop. Instant C# has created a temporary variable in order to use the initial value of rangeList.Length - 1 for every iteration:
int ForTemp1 = rangeList.Length - 1;
for (int i = 2; i <= ForTemp1; i++)
{
columnSpanRange = Globals.ExcelApplication.Union(columnSpanRange, rangeList[i]);
}
break;
}
}
// Number of data rows containing data
public int RowCount
{
get
{
return myRowCount;
}
set
{
myRowCount = value;
}
}
// First column of report area.
public int FirstColumn
{
get
{
return columnSpanRange.Column;
}
}
// Last column of report area.
public int LastColumn
{
get
{
return FirstColumn + columnSpanRange.Count - 1;
}
}
// First row of report area
public int FirstRow
{
get
{
return columnSpanRange.Row;
}
}
// Last row of report area
public int LastRow
{
get
{
return FirstRow + RowCount - 1;
}
}
// Are we in the processing of populating the display
public bool IsDisplaying
{
get
{
return myIsDisplaying;
}
set
{
myIsDisplaying = value;
}
}
// Currently selected range
public Excel.Range ActiveRange
{
get
{
return myActiveRange;
}
}
// Worksheet managed by the specific worksheet class
public Excel.Worksheet ExcelWorksheet
{
get
{
return myWorksheet;
}
}
// Activate the current sheet insuring that it is visible and that grid lines are not displayed
public void ActivateSheet()
{
ExcelWorksheet.Visible = Excel.XlSheetVisibility.xlSheetVisible;
ExcelWorksheet.Activate();
Globals.ExcelApplication.ActiveWindow.DisplayGridlines = false;
}
// Create a range over the cell specified by the column and row values on the specified worksheet
public Excel.Range CreateRange(Excel.Worksheet ws, string column, int row)
{
string rangeString = column + row.ToString();
return ws.Range(rangeString);
}
// Create a range over the cell specified by the column and row values on this worksheet
public Excel.Range CreateRange(string column, int row)
{
return CreateRange(ExcelWorksheet, column, row);
}
// Create a range using two columns specified as integers spanning several rows.
// Must convert the range from R1C1 format to A1 format to create range instance
public Excel.Range CreateRange(int startColumn, int startRow, int endColumn, int endRow)
{
string rangeR1C1 = string.Format("R{0}C{1}:R{2}C{3}", startRow, startColumn, endRow, endColumn);
string rangeA1 = Globals.ExcelApplication.ConvertFormula(rangeR1C1, Excel.XlReferenceStyle.xlR1C1, Excel.XlReferenceStyle.xlA1);
return ExcelWorksheet.Range(rangeA1);
}
// Create a range using a single column specified as an integer spanning several rows.
// Must convert the range from R1C1 format to A1 format to create range instance
public Excel.Range CreateRange(int column, int startRow, int endRow)
{
string rangeR1C1 = string.Format("R{0}C{1}:R{2}C{1}", startRow, column, endRow);
string rangeA1 = Globals.ExcelApplication.ConvertFormula(rangeR1C1, Excel.XlReferenceStyle.xlR1C1, Excel.XlReferenceStyle.xlA1);
return ExcelWorksheet.Range(rangeA1);
}
// Create a range using a single column specified as an integer and a single rows.
// Must convert the range from R1C1 format to A1 format to create range instance
public Excel.Range CreateRange(int column, int row)
{
string rangeR1C1 = string.Format("R{0}C{1}", row, column);
string rangeA1 = Globals.ExcelApplication.ConvertFormula(rangeR1C1, Excel.XlReferenceStyle.xlR1C1, Excel.XlReferenceStyle.xlA1);
return ExcelWorksheet.Range(rangeA1);
}
// Create a named range over a single column / row with the column specified as a string
public Excel.Range CreateNamedRange(string rangeName, string column, int row)
{
string rangeFormula = "=" + column + row;
return CreateNamedRange(rangeName, rangeFormula);
}
// Create a named range over the specified cells
// Prepends required "=" if not included
public Excel.Range CreateNamedRange(string rangeName, string rangeFormula)
{
// If range formula does not begin with the required "=" then add it.
string tempRangeFormula = null;
//INSTANT C# WARNING: C# only evaluates the one required value of the '?' operator, while VB.NET always evaluates both values of an 'IIf' statement.
tempRangeFormula = ((rangeFormula.StartsWith("=")) ? rangeFormula : "=" + rangeFormula);
// Create the named range and return a reference
Excel.Name tempName = ExcelWorksheet.Names.Add(rangeName, tempRangeFormula);
return ExcelWorksheet.Range(rangeName);
}
// Handle SelectionChange event
// Store selected range in myActiveRange making it available to the ActiveRange property
//INSTANT C# NOTE: This method is an event handler
//ORIGINAL LINE: Protected Sub Worksheet_SelectionChange(ByVal target As Excel.Range) Handles myWorksheet.SelectionChange
protected void Worksheet_SelectionChange(Excel.Range target)
{
myActiveRange = target;
DoWorksheetSelectionChangeWork(target);
}
// Give derived class an opportunity to do additional work
protected virtual void DoWorksheetSelectionChangeWork(Excel.Range target)
{
// Default is to do nothing extra
}
// Sets the formula in the English (United States) locale. This enables code that executes
// correctly in different locales. For example, formula "=SUM (1.5, 3.0)"
// is correct in English (United States), but would fail in French (France),
// which would expect "=SOMME(1,5;3,0)". We cannot automatically translate formulas;
// instead, we are using reflection to specify the En-US locale.
public static void SetFormula(Excel.Range range, string formula)
{
// en-US culture info used to set locale independent formulas
System.Globalization.CultureInfo enUSCulture = new System.Globalization.CultureInfo(1033);
// Type descripter for Excel.Range - allows us to set the Formula property using reflection
Type rangeType = typeof(Excel.Range);
// Set the range's Formula property indicating that the formula being assigned is formatted as en-US culture
// Runtime will automatically translate the formula to the actual culture
rangeType.InvokeMember("Formula", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.SetProperty, null, range, new object[] {formula}, enUSCulture);
}
// Each worksheet provides their own implementation as determining the selected symbol is different for each
// This method is called when initiating a new Stock Allocation while anther sheet is active. If the sheet returns a
// non-empty string, the Stock Allocation sheet will automatically select the corresponding symbol
public virtual string GetActiveStockSymbol()
{
return string.Empty;
}
// The workshet specific mechanism for redrawing the worksheet contents
// Used primarily when some event has changed the contents of the DataSet such as a price update
// or an applied allocation.
public abstract void Refresh();
// Format the borders around the data
protected void FormatDataBorders(bool displayHorizontal)
{
// Create range over data area
// Dim rangeString As String = String.Format("{0}{1}:{2}{3}", startingColumn, startingRow, endingColumn, myEndingRow)
Excel.Range rng = CreateRange(FirstColumn, FirstRow, LastColumn, LastRow);
// Format horozontal borders within the range
if (RowCount > 1)
{
if (displayHorizontal)
{
rng.Borders(Excel.XlBordersIndex.xlInsideHorizontal).LineStyle = Excel.XlLineStyle.xlContinuous;
rng.Borders(Excel.XlBordersIndex.xlInsideHorizontal).Weight = Excel.XlBorderWeight.xlThin;
rng.Borders(Excel.XlBordersIndex.xlInsideHorizontal).ColorIndex = Excel.XlColorIndex.xlColorIndexAutomatic;
}
else
{
rng.Borders(Excel.XlBordersIndex.xlInsideHorizontal).LineStyle = Excel.XlLineStyle.xlLineStyleNone;
}
// Format vertical borders within the range
rng.Borders(Excel.XlBordersIndex.xlInsideVertical).LineStyle = Excel.XlLineStyle.xlContinuous;
rng.Borders(Excel.XlBordersIndex.xlInsideVertical).Weight = Excel.XlBorderWeight.xlThin;
rng.Borders(Excel.XlBordersIndex.xlInsideVertical).ColorIndex = Excel.XlColorIndex.xlColorIndexAutomatic;
}
// Format bottom border
rng.Borders(Excel.XlBordersIndex.xlEdgeBottom).LineStyle = Excel.XlLineStyle.xlContinuous;
rng.Borders(Excel.XlBordersIndex.xlEdgeBottom).Weight = Excel.XlBorderWeight.xlMedium;
rng.Borders(Excel.XlBordersIndex.xlEdgeBottom).ColorIndex = Excel.XlColorIndex.xlColorIndexAutomatic;
// Format left border
rng.Borders(Excel.XlBordersIndex.xlEdgeLeft).LineStyle = Excel.XlLineStyle.xlContinuous;
rng.Borders(Excel.XlBordersIndex.xlEdgeLeft).Weight = Excel.XlBorderWeight.xlMedium;
rng.Borders(Excel.XlBordersIndex.xlEdgeLeft).ColorIndex = Excel.XlColorIndex.xlColorIndexAutomatic;
// Format right border
rng.Borders(Excel.XlBordersIndex.xlEdgeRight).LineStyle = Excel.XlLineStyle.xlContinuous;
rng.Borders(Excel.XlBordersIndex.xlEdgeRight).Weight = Excel.XlBorderWeight.xlMedium;
rng.Borders(Excel.XlBordersIndex.xlEdgeRight).ColorIndex = Excel.XlColorIndex.xlColorIndexAutomatic;
// Format top border
rng.Borders(Excel.XlBordersIndex.xlEdgeTop).LineStyle = Excel.XlLineStyle.xlContinuous;
rng.Borders(Excel.XlBordersIndex.xlEdgeTop).Weight = Excel.XlBorderWeight.xlMedium;
rng.Borders(Excel.XlBordersIndex.xlEdgeTop).ColorIndex = Excel.XlColorIndex.xlColorIndexAutomatic;
}
// Removes the contents of all cells within the specified range
// Function is used primarily to delete the existing data contents of a sheet so that it can
// be repopulated.
protected void ClearContents()
{
// Protected Sub ClearContents(ByVal startingRow As Integer, ByVal startingColumn As String, ByVal endingColumn As String, ByVal resetBorders As Boolean)
if (RowCount > 0)
{
// Create range over data rows
Excel.Range rng = CreateRange(FirstColumn, FirstRow, LastColumn, LastRow);
// Remove data from all cells in range
rng.ClearContents();
// Delete all rows except the first so as to not lose cell formatting
if (RowCount > 1)
{
rng = CreateRange(FirstColumn, FirstRow + 1, LastColumn, LastRow);
//rng.Select()
//Globals.ExcelApplication.Selection.Delete(Excel.XlDirection.xlUp)
rng.Delete(Excel.XlDirection.xlUp);
}
// Delete all charts
ExcelWorksheet.ChartObjects.Delete();
// Reset row count
RowCount = 0;
}
}
// Converts the chart name returned from the ActiveChart.Name property to the format
// expected by the ActiveSheet members such as ActiveSheet.DrawingObjects and
// ActiveSheet.Shapes. The ActiveChart.Name property returns the name with the
// containing sheet name prepended (ex: "Account Summary Chart 1") but the ActiveSheet
// members do not expect the sheet name to be prepended (ex: "Chart 1") so this function
// strips the name down to the non-sheet-name portion
public string GetActiveChartName()
{
string chartName = Globals.ExcelApplication.ActiveChart.Name;
return chartName.Substring(chartName.IndexOf("Chart"));
}
// Details of creating chart members
public Excel.Shape CreateChart(string sheetName, Excel.XlChartType chartType, Excel.Range rng, string title, int foreColor, int backColor, int top, int left, int height, int width)
{
Excel.Chart excelChart = Globals.ExcelApplication.Charts.Add();
excelChart.ChartType = chartType;
excelChart.SetSourceData(rng, Excel.XlRowCol.xlColumns);
excelChart.HasTitle = true;
excelChart.ChartTitle.Text = title;
excelChart.HasLegend = false;
if (chartType == Excel.XlChartType.xl3DPieExploded)
{
excelChart.ApplyDataLabels(Excel.XlDataLabelsType.xlDataLabelsShowLabel);
excelChart.PlotArea.Interior.ColorIndex = Excel.XlColorIndex.xlColorIndexNone;
excelChart.PlotArea.Border.LineStyle = Excel.XlLineStyle.xlLineStyleNone;
}
excelChart.Location(Excel.XlChartLocation.xlLocationAsObject, sheetName);
Globals.ExcelApplication.Selection.Border.LineStyle = CHART_BORDER_LINE_STYLE;
FillSelectionWithGradient(Office.MsoGradientStyle.msoGradientDiagonalUp, foreColor, backColor);
Globals.ExcelApplication.ActiveSheet.DrawingObjects(GetActiveChartName()).Shadow = true;
if (chartType == Excel.XlChartType.xl3DBarClustered)
{
Globals.ExcelApplication.ActiveChart.Walls.Select();
FillSelectionWithGradient(Office.MsoGradientStyle.msoGradientHorizontal, CHART_WALL_FORECOLOR, CHART_WALL_BACKCOLOR);
Globals.ExcelApplication.ActiveChart.SeriesCollection(1).Select();
Globals.ExcelApplication.Selection.Interior.ColorIndex = BARCHART_SERIES_COLOR;
Globals.ExcelApplication.ActiveChart.Axes(Excel.XlAxisType.xlCategory).TickLabelSpacing = BARCHART_SHOW_ALL_TICK_LABELS;
}
Excel.Shape excelShape = Globals.ExcelApplication.ActiveSheet.Shapes(GetActiveChartName());
excelShape.Top = top;
excelShape.Left = left;
excelShape.Height = height;
excelShape.Width = width;
SetActiveChartFonts();
return excelShape;
}
// Create range for charts using the ranges specifying the lable and value columns
// Charts are a special case as they actually span two sets of columns
public Excel.Range CreateChartRange(Excel.Range label, Excel.Range value)
{
string rangeR1C1 = string.Format("R{0}C{1}:R{2}C{1},R{3}C{4}:R{5}C{4}", label.Row, label.Column, label.Row + RowCount - 1, value.Row, value.Column, value.Row + RowCount - 1);
string rangeA1 = Globals.ExcelApplication.ConvertFormula(rangeR1C1, Excel.XlReferenceStyle.xlR1C1, Excel.XlReferenceStyle.xlA1);
return ExcelWorksheet.Range(rangeA1);
}
// Handles details of setting the current selection to a compound color gradient
protected void FillSelectionWithGradient(Office.MsoGradientStyle gradientStyle, int foreColor, int backColor)
{
Globals.ExcelApplication.Selection.Fill.TwoColorGradient(gradientStyle, 1);
Globals.ExcelApplication.Selection.Fill.Visible = true;
Globals.ExcelApplication.Selection.Fill.ForeColor.SchemeColor = foreColor;
Globals.ExcelApplication.Selection.Fill.BackColor.SchemeColor = backColor;
}
// Setup chart fonts
protected void SetActiveChartFonts()
{
Globals.ExcelApplication.ActiveChart.ChartTitle.Font.Name = "Arial";
Globals.ExcelApplication.ActiveChart.ChartTitle.Font.FontStyle = "Bold";
Globals.ExcelApplication.ActiveChart.ChartTitle.Font.Size = 11;
if (Globals.ExcelApplication.ActiveChart.ChartType == Excel.XlChartType.xl3DBarClustered)
{
if (Globals.ExcelApplication.ActiveChart.HasAxis(Excel.XlAxisType.xlCategory))
{
Globals.ExcelApplication.ActiveChart.Axes(Excel.XlAxisType.xlCategory).Select();
Globals.ExcelApplication.Selection.TickLabels.AutoScaleFont = false;
Globals.ExcelApplication.Selection.TickLabels.Font.Name = "Arial";
Globals.ExcelApplication.Selection.TickLabels.Font.FontStyle = "Bold";
Globals.ExcelApplication.Selection.TickLabels.Font.Size = 8;
}
if (Globals.ExcelApplication.ActiveChart.HasAxis(Excel.XlAxisType.xlValue))
{
Globals.ExcelApplication.ActiveChart.Axes(Excel.XlAxisType.xlValue).Select();
Globals.ExcelApplication.Selection.TickLabels.AutoScaleFont = false;
Globals.ExcelApplication.Selection.TickLabels.Font.Name = "Arial";
Globals.ExcelApplication.Selection.TickLabels.Font.FontStyle = "Regular";
Globals.ExcelApplication.Selection.TickLabels.Font.Size = 8;
}
}
else if (Globals.ExcelApplication.ActiveChart.ChartType == Excel.XlChartType.xl3DPieExploded)
{
Globals.ExcelApplication.ActiveChart.SeriesCollection(1).DataLabels.Select();
Globals.ExcelApplication.Selection.AutoScaleFont = false;
Globals.ExcelApplication.Selection.Font.Name = "Arial";
Globals.ExcelApplication.Selection.Font.FontStyle = "Bold";
Globals.ExcelApplication.Selection.Font.Size = 8;
}
}
}
David Anton
Tangible Software Solutions
www.tangiblesoftwaresolutions.com
Home of the Instant C# VB.NET to C# Converter and the Instant VB C# to VB.NET Converter
|
|
|
|
|
Hi, I couldn't compile your program. The error seems to be when running CallCocoR which in turns call coco.
The error is the foloowing:
Coco/R for C# V1.11-PDT (04 November 2002)
Original by Hanspeter Moessenboeck (moessenboeck@ssw.uni-linz.ac.at)
Modifications by Pat Terry (p.terry@ru.ac.za)
More Modifications by Daniel Turini (dturini@crivo.com.br)
VBNET.ATG (565 , 1) attribute mismatch between declaration and use of this symbol
VBNET.ATG (699 , 1) attribute mismatch between declaration and use of this symbol
2 errors detected
Any suggestions??
|
|
|
|
|
I've modified the VBNET.ATG file and the Util.cs as I've been using GBVB. I've not documented the changes or anything but I provide them here in case they are of use to anyone else.
There's slightly better handling of Arrays, AddHandler statements and one or two other tweaks.
VBNET.ATG
using GBVB;<br />
<br />
COMPILER VBNET<br />
<br />
public Util util;<br />
<br />
CHARACTERS<br />
<br />
digit = "0123456789".<br />
letter = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".<br />
cr = "\r".<br />
lf = "\n".<br />
crlf = cr+lf.<br />
space = " \t".<br />
anyclose = ANY - "]".<br />
stringChars = ANY - "\"".<br />
<br />
TOKENS<br />
<br />
number = digit { digit } [ "." digit { digit } ].<br />
quotedString = "\"" { stringChars | "\"\"" } "\"".<br />
identifier = (letter | "_") { letter | "_" | "." | digit }.<br />
IGNORE space + crlf + "_"<br />
COMMENTS FROM "'" TO cr<br />
<br />
PRODUCTIONS<br />
<br />
VBNET = <br />
{ OptionStmt }<br />
{ ImportStmt }<br />
[ AttributeList ] br />
ClassStmt<br />
.<br />
<br />
ClassStmt<br />
=<br />
ClassGroup {<br />
ClassGroup<br />
}<br />
(.<br />
util.Writeline("");<br />
util.WriteDelegates();<br />
.)<br />
.<br />
<br />
ClassGroup<br />
=<br />
(. <br />
string modifier = "";<br />
.)<br />
[ ModifierGroup<out modifier> ] br />
TypeDeclaration<modifier><br />
.<br />
<br />
ModifierGroup<out string modgroup> (. <br />
string modifier;<br />
modgroup = ""; .)<br />
=<br />
Modifier<out modifier> (. modgroup += modifier;<br />
modgroup += " "; <br />
.)<br />
{<br />
Modifier<out modifier> (. modgroup += modifier; <br />
modgroup += " "; <br />
.)<br />
}<br />
.<br />
<br />
ImportStmt = (. string nmspc; .)<br />
"Imports"<br />
QualName<out nmspc> (. util.Writeline("using " + nmspc + ";"); .)<br />
.<br />
<br />
OptionStmt =<br />
"Option"<br />
(<br />
"Explicit" ["On" | "Off"]<br />
|<br />
"Strict" ["On" | "Off"]<br />
|<br />
"Compare" ["Text" | "Binary"]<br />
)<br />
.<br />
<br />
InheritanceDecl<out string decl> =<br />
(. string typename; .)<br />
"Inherits"<br />
QualName<out typename> (. decl = " : " + typename; .)<br />
.<br />
<br />
ImplementsDecl<ref string decl> =<br />
(. string typename; .)<br />
"Implements"<br />
QualName<out typename> (.<br />
if (decl == "")<br />
decl = " : " + typename;<br />
else<br />
decl += ", " + typename;<br />
.)<br />
{<br />
","<br />
QualName<out typename> (.<br />
decl += ", " + typename;<br />
.)<br />
}<br />
.<br />
<br />
TypeDeclaration<string modifier><br />
=<br />
(.<br />
string bases = "";<br />
string decl = modifier;<br />
string typename;<br />
.)<br />
(<br />
"Class" (. decl += "class "; .)<br />
| "Structure" (. decl += "struct "; .)<br />
)<br />
QualName<out typename> <br />
(. <br />
decl += typename;<br />
util.PushClassName(typename);<br />
.)<br />
[<br />
InheritanceDecl<out bases><br />
]<br />
[<br />
ImplementsDecl<ref bases><br />
] (. decl += bases; .)<br />
(.<br />
util.Writeline(decl);<br />
util.OpenBlock();<br />
.)<br />
{ MemberDeclaration }<br />
"End" ("Class" | "Module") (.<br />
util.CloseBlock();<br />
util.PopClassName();<br />
.)<br />
.<br />
<br />
ArithOp<out string op> =<br />
(. op = ""; .)<br />
(<br />
("+=" | "-=" | "+" | "-" | "*" | "/" ) (. op = token.val; .)<br />
| "\\" (. op = "/"; .)<br />
| "Mod" (. op = "%"; .)<br />
| "&" (. op = "+"; .)<br />
| "Not" (. op = "!"; .) <br />
| BoolOp<out op><br />
| LogicalOp<out op><br />
)<br />
.<br />
<br />
ArithExpr<out string exp> =<br />
(. string op, exp2; .)<br />
ArithOp<out op><br />
Expression<out exp2> (. exp = op + " " + exp2; .)<br />
.<br />
<br />
TypeOfExp<out string exp> =<br />
(. string exp2, typespec; .)<br />
"TypeOf"<br />
QualName<out exp2><br />
"Is"<br />
QualName<out typespec> (. exp = exp2 + " is " + typespec; .)<br />
.<br />
<br />
CTypeExp<out string exp> =<br />
(.<br />
string exp2, typespec, exp3;<br />
.)<br />
"CType"<br />
"("<br />
Expression<out exp2><br />
","<br />
QualName<out typespec><br />
[<br />
"(" (. typespec += "["; .)<br />
ExpressionList<out exp3> (. typespec += exp3; .)<br />
")" (. typespec += "]"; .)<br />
]<br />
")"<br />
(.<br />
exp = "((" + typespec + ")" + exp2 + ")";<br />
.)<br />
.<br />
CObjExp<out string exp> =<br />
(.<br />
string exp2;<br />
.)<br />
"CObj"<br />
"("<br />
Expression<out exp2><br />
")"<br />
(.<br />
exp = "((object)" + exp2 + ")";<br />
.)<br />
.<br />
<br />
ParentExp<out string exp> =<br />
(. <br />
string exp2;<br />
.)<br />
"(" <br />
Expression<out exp2><br />
")" (. exp = "(" + exp2 + ")"; .)<br />
.<br />
<br />
Expression<out string exp> =<br />
(. <br />
string parms = "";<br />
string typename;<br />
string exp2 = "";<br />
exp = "";<br />
.)<br />
(<br />
"True" (. exp = "true"; .)<br />
|<br />
"False" (. exp = "false"; .)<br />
|<br />
"Nothing" (. exp = "null"; .)<br />
|<br />
"Me" (. exp = "this"; .)<br />
|<br />
"MyBase" (. exp = "base"; .)<br />
|<br />
TypeOfExp<out exp><br />
<br />
|<br />
CTypeExp<out exp><br />
|<br />
CObjExp<out exp><br />
|<br />
NumericConstant<out exp><br />
|<br />
StringConstant<out exp><br />
|<br />
ParentExp<out exp><br />
|<br />
QualName<out exp><br />
[<br />
(<br />
"Is" "Nothing" (. exp += " == null"; .)<br />
|<br />
Callparms<out parms> (. exp += parms; .)<br />
[<br />
"."<br />
Expression<out exp2> (. exp += "." + exp2; .)<br />
]<br />
)<br />
]<br />
|<br />
"New"<br />
QualName<out typename><br />
[<br />
Callparms<out parms> <br />
] (. <br />
if (parms == null || parms == "")<br />
parms = "()";<br />
exp = "new " + typename + parms; <br />
<br />
.)<br />
)<br />
[<br />
ArithExpr<out exp2> (. exp += exp2; .)<br />
]<br />
.<br />
<br />
LogicalOp<out string op><br />
=<br />
("=" | "<" | ">" | ">=" | "<=" | "<>") (. op = util.ConverteLogicalOp(token.val); .)<br />
.<br />
<br />
BoolOp<out string op><br />
=<br />
(. op = ""; .)<br />
(<br />
"And" (. op = " && "; .)<br />
|<br />
"AndAlso" (. op = " && "; .)<br />
|<br />
"Or" (. op = " || "; .)<br />
|<br />
"OrElse" (. op = " || "; .)<br />
)<br />
.<br />
<br />
NumericConstant<out string exp> =<br />
number (. exp = token.val; .)<br />
.<br />
<br />
StringConstant<out string exp> =<br />
quotedString (. exp = util.ConverteString(token.val); .)<br />
.<br />
<br />
ExpressionList<out string expList> =<br />
(. string exp; .)<br />
Expression<out exp> (. expList = exp; .)<br />
{<br />
"," (. expList += token.val + ""; .)<br />
Expression<out exp> (. expList += exp; .)<br />
}<br />
.<br />
<br />
Callparms<out string parms> =<br />
(. string expList; .)<br />
"(" (. parms = token.val; .)<br />
[<br />
ExpressionList<out expList> (. parms += expList; .)<br />
]<br />
")" (. parms += token.val; .)<br />
[<br />
"(" (. parms += "["; .)<br />
ExpressionList<out expList> (. parms += expList; .)<br />
")" (. parms += "]"; .)<br />
]<br />
.<br />
<br />
AttribSpec<out string attspec> =<br />
(. <br />
string pl;<br />
string typename;<br />
.)<br />
QualName<out typename> (. attspec = typename; .)<br />
[<br />
Callparms<out pl> (. attspec += pl; .)<br />
]<br />
.<br />
<br />
AttributeList =<br />
(. string attlist; <br />
string attspec;<br />
.)<br />
"<"<br />
AttribSpec<out attlist><br />
{<br />
"," (. attlist += token.val; .)<br />
AttribSpec<out attspec> (. attlist += attspec; .)<br />
}<br />
">"<br />
(.<br />
util.Writeline("[" + attlist + "]");<br />
.)<br />
.<br />
<br />
Modifier<out string modifier> =<br />
("Public" | "Private" | "Protected" | "Overrides" | "Shared" | "Friend" | "WithEvents" | "Overloads" | "Shadows" | "ReadOnly")<br />
(.<br />
modifier = util.ConvertModifier(token.val);<br />
.)<br />
.<br />
<br />
MemberDeclaration =<br />
(.<br />
string modifier = "";<br />
.)<br />
[ AttributeList ] br />
[ ModifierGroup<out modifier> ] br />
(<br />
InterfaceDeclaration<modifier><br />
|<br />
TypeDeclaration<modifier><br />
|<br />
EventDeclaration<modifier><br />
|<br />
EnumDeclaration<modifier><br />
|<br />
PropertyDeclaration<modifier><br />
|<br />
SubDeclaration<modifier><br />
|<br />
FunctionDeclaration<modifier><br />
|<br />
ConstDeclaration<modifier><br />
|<br />
FieldDeclaration<modifier><br />
|<br />
BeginRegion<br />
|<br />
EndRegion<br />
).<br />
<br />
InterfaceDeclaration<string modifier><br />
=<br />
"Interface"<br />
identifier (.<br />
util.Writeline(modifier + "interface " + token.val);<br />
util.OpenBlock();<br />
.)<br />
{<br />
SubHeader<""> | FunctionHeader<""><br />
}<br />
"End" "Interface" (. util.CloseBlock(); .)<br />
.<br />
<br />
<br />
EnumDeclaration<string modifier><br />
=<br />
(. <br />
string constName;<br />
string constValue;<br />
.)<br />
"Enum" <br />
identifier (.<br />
util.Writeline(modifier + " enum " + token.val);<br />
util.OpenBlock();<br />
.)<br />
{<br />
identifier (. constName = token.val; constValue = null; .)<br />
[ "="<br />
Expression<out constValue><br />
] (.<br />
if (constValue == null)<br />
util.Writeline(constName);<br />
else<br />
util.Writeline(constName + " = " + constValue);<br />
.)<br />
}<br />
"End" "Enum" (. util.CloseBlock(); .)<br />
.<br />
<br />
BeginRegion =<br />
"#Region"<br />
quotedString (. util.Writeline("#region " + token.val); .)<br />
.<br />
<br />
EndRegion =<br />
"#End"<br />
"Region" (. <br />
util.Writeline("#endregion");<br />
util.Writeline("");<br />
.)<br />
.<br />
<br />
ConstDeclaration<string modifier> = (. string decl; .)<br />
"Const"<br />
VarDeclaration<out decl> (. util.Writeline(modifier + "const " + decl + ";"); .)<br />
.<br />
<br />
FieldDeclaration<string modifier> = (. string decl; .)<br />
VarDeclaration<out decl> (. util.Writeline(modifier + decl + ";"); .)<br />
.<br />
<br />
QualName<out string typename> =<br />
identifier (. typename = util.ConverteTipo(token.val); .)<br />
.<br />
<br />
DeclQualName<out string typename> =<br />
identifier (. typename = util.ConverteTipo(token.val); .)<br />
[<br />
"("<br />
")" (. typename += "[]"; .)<br />
]<br />
.<br />
<br />
<br />
<br />
VarDeclaration<out string declaration> =<br />
(. string typename;<br />
string varname;<br />
string exp;<br />
string dimensions = null;<br />
bool bIsArray = false;<br />
string parms = "";<br />
declaration = "";<br />
.)<br />
QualName<out varname><br />
[<br />
"("<br />
ExpressionList<out dimensions><br />
")" (. bIsArray = true; .)<br />
]<br />
"As"<br />
(<br />
"New"<br />
QualName<out typename> <br />
[<br />
Callparms<out parms><br />
] (.<br />
if (parms == "" ) parms = "()";<br />
declaration = typename + " " + varname + " = new " + typename + parms;<br />
.)<br />
|<br />
QualName<out typename> (.<br />
if (!bIsArray)<br />
declaration = typename + " " + varname;<br />
else {<br />
declaration = String.Format("{0}[{1}] {2}", typename, dimensions, varname);<br />
}<br />
.)<br />
)<br />
[<br />
"="<br />
Expression<out exp> (. declaration += " = " + exp; .)<br />
]<br />
.<br />
<br />
SubImplementsInterface =<br />
(.<br />
string lixo;<br />
.)<br />
"Implements"<br />
QualName<out lixo><br />
.<br />
<br />
Handles =<br />
(.<br />
string lixo;<br />
.)<br />
"Handles"<br />
QualName<out lixo><br />
.<br />
<br />
BaseNewStmt<out string exp>=<br />
(.<br />
string parms = "";<br />
.)<br />
"MyBase.New" <br />
"("<br />
[<br />
ExpressionList<out parms><br />
]<br />
")"<br />
(.<br />
exp = "base(" + parms + ")";<br />
.)<br />
.<br />
<br />
MeNewStmt<out string exp>=<br />
(.<br />
string parms = "";<br />
.)<br />
"Me.New" <br />
"("<br />
[<br />
ExpressionList<out parms><br />
]<br />
")"<br />
(.<br />
exp = "this(" + parms + ")";<br />
.)<br />
.<br />
<br />
CtorStmt<ref string exp>=<br />
BaseNewStmt<out exp><br />
|<br />
MeNewStmt<out exp><br />
.<br />
<br />
CtorGroup<ref string exp>=<br />
(.<br />
string exp2 = "";<br />
.)<br />
CtorStmt<ref exp> <br />
{<br />
CtorStmt<ref exp2> (.<br />
exp += ", ";<br />
exp += exp2;<br />
.)<br />
}<br />
.<br />
<br />
SubHeader<string modifier> =<br />
(.<br />
string decl = modifier;<br />
string paramList;<br />
string bases = "";<br />
.)<br />
"Sub" <br />
("New" (. decl += " " + util.GetClassName(); .)<br />
| identifier (. decl += "void " + token.val; .))<br />
[<br />
ParameterList<out paramList> (. decl += paramList; .)<br />
]<br />
[ <br />
CtorGroup<ref bases> (.<br />
if (bases != "")<br />
decl += " : " + bases;<br />
.)<br />
] br />
(.<br />
if (modifier == "")
util.Writeline(decl + ";");<br />
else<br />
util.Writeline(decl);<br />
.)<br />
[SubImplementsInterface]<br />
[Handles]<br />
.<br />
<br />
<br />
SubDeclaration<string modifier> =<br />
SubHeader<modifier> (. util.OpenBlock(); .)<br />
[RoutineBody]<br />
"End" "Sub" (. util.CloseBlock(); .)<br />
.<br />
<br />
EventDeclaration<string modifier> =<br />
(.<br />
string decl = modifier;<br />
string paramList = "";<br />
string evtname = "";<br />
.)<br />
"Event" (. decl += "event "; .)<br />
identifier (. evtname = token.val; .)<br />
ParameterList<out paramList> (.<br />
decl += util.GetEvtHandlerName(paramList) + " " + evtname;<br />
<br />
util.Writeline(decl + ";");<br />
.)<br />
.<br />
<br />
RaiseEventStmt =<br />
(.<br />
string paramList = "";<br />
string evtname = "";<br />
.)<br />
"RaiseEvent"<br />
identifier (. evtname = token.val; .)<br />
"("<br />
ExpressionList<out paramList> <br />
")"<br />
(.<br />
util.Writeline("if (" + evtname + " != null)");<br />
util.OpenBlock(); <br />
util.Writeline(evtname + "(" + paramList + ");");<br />
util.CloseBlock();<br />
.)<br />
.<br />
AddHandler = <br />
(.<br />
string exp, exp2, typespec, exp3;<br />
.)<br />
"AddHandler"<br />
Expression<out exp2><br />
","<br />
"AddressOf"<br />
Expression<out typespec><br />
(. exp = exp2 + "+= new Eventhandler(" + typespec + ");"; <br />
util.Writeline(exp);<br />
.)<br />
<br />
.<br />
PropertyHeader<string modifier> =<br />
(. string funcName;<br />
string paramList = "";<br />
string returnType;<br />
.)<br />
"Property"<br />
identifier (. funcName = token.val; .)<br />
[ ParameterList<out paramList> ] br />
"As"<br />
DeclQualName<out returnType> (.<br />
util.Writeline(modifier + " " + returnType + " " + funcName);<br />
.)<br />
.<br />
<br />
<br />
PropertyGet =<br />
"Get" (.<br />
util.Writeline("get");<br />
util.OpenBlock();<br />
.)<br />
[RoutineBody]<br />
"End" "Get" (. util.CloseBlock(); .)<br />
.<br />
<br />
PropertySet = (. string paramList = ""; .)<br />
"Set"<br />
[<br />
ParameterList<out paramList> <br />
]<br />
(.<br />
util.Writeline("set");<br />
util.OpenBlock();<br />
.)<br />
[RoutineBody]<br />
"End" "Set" (. util.CloseBlock(); .)<br />
.<br />
<br />
PropertyDeclaration<string modifier> =<br />
PropertyHeader<modifier> (. util.OpenBlock(); .)<br />
PropertyBody<br />
"End" "Property" (. util.CloseBlock(); .)<br />
.<br />
<br />
PropertyBody =<br />
PropertyStmt { PropertyStmt }<br />
.<br />
<br />
PropertyStmt =<br />
PropertyGet<br />
|<br />
PropertySet<br />
.<br />
<br />
FunctionHeader<string modifier> =<br />
(. string funcName;<br />
string paramList = "";<br />
string returnType;<br />
.)<br />
"Function"<br />
identifier (. funcName = token.val; .)<br />
[ ParameterList<out paramList> ] br />
"As"<br />
DeclQualName<out returnType> (.<br />
util.Writeline(modifier + returnType + " " + funcName + paramList);<br />
.)<br />
[SubImplementsInterface]<br />
[Handles]<br />
.<br />
<br />
FunctionDeclaration<string modifier> =<br />
FunctionHeader<modifier> (. util.OpenBlock(); .)<br />
[RoutineBody]<br />
"End" "Function" (. util.CloseBlock(); .)<br />
.<br />
<br />
RoutineBody =<br />
RoutineStmt { RoutineStmt }.<br />
<br />
RoutineStmt =<br />
AssignCall<br />
|<br />
SyncLockStmt<br />
|<br />
ThrowStmt<br />
|<br />
DoWhileStmt<br />
|<br />
ExitStmt<br />
|<br />
WhileStmt<br />
|<br />
CallStmt<br />
|<br />
SelectCase<br />
|<br />
ForStmt<br />
|<br />
IfStmt<br />
|<br />
TryCatch<br />
|<br />
ReturnStmt<br />
|<br />
LocalDeclaration<br />
|<br />
RaiseEventStmt<br />
|<br />
AddHandler<br />
.<br />
<br />
SyncLockStmt =<br />
(. string exp; .)<br />
"SyncLock"<br />
Expression<out exp> (. <br />
util.Writeline("lock (" + exp + ")");<br />
util.OpenBlock();<br />
.)<br />
[RoutineBody]<br />
"End" "SyncLock" (. util.CloseBlock(); .)<br />
.<br />
<br />
ThrowStmt =<br />
(. string exp; .)<br />
"Throw"<br />
Expression<out exp> (. util.Writeline("throw " + exp + ";"); .)<br />
.<br />
<br />
DoWhileStmt =<br />
(. string exp; .)<br />
"Do"<br />
(<br />
"While" Expression<out exp> (. <br />
util.Writeline("while (" + exp + ")");<br />
util.OpenBlock();<br />
.)<br />
|<br />
(. <br />
util.Writeline("do");<br />
util.OpenBlock();<br />
.)<br />
)<br />
RoutineBody<br />
"Loop"<br />
(<br />
"While" Expression<out exp> (. <br />
util.CloseBlock();<br />
util.Writeline("while (" + exp + ")");<br />
.)<br />
|<br />
"Until" Expression<out exp> (. <br />
util.CloseBlock();<br />
util.Writeline("while (!(" + exp + "))");<br />
.)<br />
|<br />
(. <br />
util.CloseBlock();<br />
.)<br />
)<br />
.<br />
<br />
ExitStmt =<br />
"Exit"<br />
("For" | "While" | "Do") (. util.Writeline("break;"); .)<br />
.<br />
<br />
WhileStmt =<br />
(. string exp; .)<br />
"While"<br />
Expression<out exp> (. <br />
util.Writeline("while (" + exp + ")");<br />
util.OpenBlock();<br />
.)<br />
[RoutineBody]<br />
"End" "While" (. util.CloseBlock(); .)<br />
.<br />
<br />
ForVar =<br />
(.<br />
string loopvar;<br />
string expIni;<br />
string expEnd;<br />
string stepExp;<br />
string stepCS;<br />
.)<br />
QualName<out loopvar> (. stepCS = loopvar + "++"; .)<br />
"="<br />
Expression<out expIni><br />
"To"<br />
Expression<out expEnd><br />
[<br />
"Step"<br />
Expression<out stepExp> (. stepCS = loopvar + " += " + stepExp; .)<br />
] (.<br />
util.Writeline(string.Format("for ({0}={1}; {0} <= {2}; {3})", loopvar, expIni, expEnd, stepCS));<br />
util.OpenBlock();<br />
.)<br />
RoutineBody<br />
"Next" [identifier] (.<br />
util.CloseBlock();<br />
.)<br />
.<br />
<br />
ForEach =<br />
(.<br />
string loopvar;<br />
string expIni;<br />
.)<br />
"Each"<br />
QualName<out loopvar><br />
"In"<br />
Expression<out expIni><br />
(.<br />
util.Writeline(string.Format("foreach ({0} in {1})", loopvar, expIni));<br />
util.OpenBlock();<br />
.)<br />
RoutineBody<br />
"Next" [identifier] (.<br />
util.CloseBlock();<br />
.)<br />
.<br />
<br />
<br />
ForStmt =<br />
"For"<br />
(<br />
ForVar<br />
|<br />
ForEach<br />
)<br />
.<br />
<br />
CallStmt =<br />
(. <br />
string funcname;<br />
string parms = "";<br />
.)<br />
"Call"<br />
QualName<out funcname><br />
[<br />
Callparms<out parms><br />
] (. util.Writeline(funcname + parms + ";"); .)<br />
.<br />
<br />
ReturnStmt =<br />
(. string exp; .)<br />
"Return"<br />
Expression<out exp> (. util.Writeline("return " + exp + ";"); .)<br />
.<br />
<br />
TryCatch =<br />
(. string varname = "Exception"; .)<br />
"Try" (.<br />
util.Writeline("try");<br />
util.OpenBlock();<br />
.)<br />
RoutineBody<br />
[<br />
"Catch"<br />
[<br />
VarDeclaration<out varname><br />
] (.<br />
util.CloseBlock();<br />
util.Writeline("catch (" + varname + ")");<br />
util.OpenBlock();<br />
.)<br />
[RoutineBody]<br />
]<br />
[<br />
"Finally" (.<br />
util.CloseBlock();<br />
util.Writeline("finally");<br />
util.OpenBlock();<br />
.)<br />
RoutineBody<br />
]<br />
"End" "Try" (.<br />
util.CloseBlock();<br />
.)<br />
.<br />
<br />
SelectCase =<br />
(. string exp; .)<br />
"Select" "Case"<br />
Expression<out exp><br />
(.<br />
util.Writeline("switch (" + exp + ")");<br />
util.OpenBlock();<br />
.)<br />
CaseStmts<br />
"End" "Select" (. util.CloseBlock(); .)<br />
.<br />
<br />
CaseStmt =<br />
(. string exp; .)<br />
"Case"<br />
(<br />
"Else" (.<br />
util.Writeline("default:");<br />
util.Ident();<br />
.)<br />
<br />
|<br />
Expression<out exp> (. <br />
util.Writeline("case " + exp + ":");<br />
util.Ident();<br />
.)<br />
{<br />
","<br />
Expression<out exp> (.<br />
util.Unident();<br />
util.Writeline("case " + exp + ":");<br />
util.Ident();<br />
.)<br />
} <br />
)<br />
<br />
RoutineBody (.util.Writeline("break;"); .)<br />
(.<br />
util.Unident();<br />
.)<br />
.<br />
<br />
CaseStmts =<br />
CaseStmt<br />
{ CaseStmt }<br />
.<br />
<br />
ElseStmt =<br />
(. string exp; .)<br />
("Else" (.<br />
util.CloseBlock();<br />
util.Writeline("else");<br />
util.OpenBlock();<br />
.)<br />
RoutineBody<br />
|<br />
"ElseIf"<br />
Expression<out exp><br />
"Then" (. util.CloseBlock();<br />
util.Writeline("else if (" + exp + ")");<br />
util.OpenBlock();<br />
.)<br />
RoutineBody<br />
[ElseStmt]<br />
)<br />
.<br />
<br />
IfStmt =<br />
(. string exp; .)<br />
"If"<br />
Expression<out exp><br />
"Then" (. <br />
util.Writeline("if (" + exp + ")");<br />
util.OpenBlock();<br />
.)<br />
RoutineBody<br />
[ElseStmt]<br />
"End" "If" (.<br />
util.CloseBlock();<br />
.)<br />
.<br />
<br />
LeftAssign<out string call> =<br />
(. string typename, pl, call2; .)<br />
QualName<out typename> (. call = typename; .)<br />
[<br />
Callparms<out pl> (. call += pl; .)<br />
[<br />
"."<br />
LeftAssign<out call2> (. call += "." + call2; .)<br />
]<br />
]<br />
.<br />
<br />
AssignCall =<br />
(. string call;<br />
string operation = "";<br />
string rvalue = null;<br />
.)<br />
LeftAssign<out call><br />
[<br />
[<br />
"+=" (. operation = token.val; .)<br />
| <br />
"-=" (. operation = token.val; .)<br />
| <br />
"+" (. operation = token.val; .)<br />
| <br />
"-" (. operation = token.val; .)<br />
| <br />
"*" (. operation = token.val; .)<br />
| <br />
"/" (. operation = token.val; .)<br />
| <br />
"&" (. operation = token.val; .)<br />
]<br />
"="<br />
Expression<out rvalue><br />
] (. <br />
if (rvalue != null)<br />
if (operation != "")<br />
util.Writeline(call + " " + operation + " " + rvalue + ";");<br />
else<br />
util.Writeline(call + " " + "= " + rvalue + ";");<br />
else<br />
util.Writeline(call + ";");<br />
.)<br />
.<br />
<br />
LocalDeclaration =<br />
(.<br />
string decl;<br />
string constant = "";<br />
.)<br />
(<br />
"Dim"<br />
|<br />
"Const" (. constant = "const "; .)<br />
)<br />
VarDeclaration<out decl> (. util.Writeline(constant + decl + ";"); .)<br />
{ ","<br />
VarDeclaration<out decl> (. util.Writeline(constant + decl + ";"); .)<br />
}<br />
.<br />
<br />
ParameterList<out string paramList> =<br />
(. string decl; .)<br />
"(" (. paramList = token.val; .)<br />
[<br />
ParameterDeclaration<out decl> (. paramList += decl; .)<br />
{<br />
"," (. paramList += token.val + " "; .)<br />
ParameterDeclaration<out decl> (. paramList += decl; .)<br />
}<br />
]<br />
")" (. paramList += token.val; .)<br />
.<br />
<br />
ParameterDeclaration<out string declaration> =<br />
(. string decl; .)<br />
["ByVal" | "ByRef"]" (. declaration = util.ConvertByX(token.val); .)<br />
VarDeclaration<out decl> (. declaration += decl; .)<br />
.<br />
<br />
<br />
<br />
END VBNET.<br />
Util.cs
using VBNET;<br />
using System;<br />
using System.IO;<br />
using System.Collections.Specialized;<br />
<br />
namespace GBVB<br />
{<br />
public class Util<br />
{<br />
string identStr = "";<br />
<br />
public TextWriter output;<br />
<br />
StringCollection linePush = new StringCollection();<br />
System.Collections.Stack stackClassname = new System.Collections.Stack();<br />
System.Collections.Hashtable evtHandleTable = new System.Collections.Hashtable();<br />
<br />
public void PushClassName(string classname)<br />
{<br />
stackClassname.Push(classname);<br />
}<br />
<br />
public void PopClassName()<br />
{<br />
stackClassname.Pop();<br />
}<br />
<br />
public string GetClassName()<br />
{<br />
object classname = stackClassname.Peek();<br />
if (classname == null)<br />
return "";<br />
<br />
return (string)classname;<br />
}<br />
<br />
public string GetEvtHandlerName(string paramlist)<br />
{<br />
if (evtHandleTable.ContainsKey(paramlist))<br />
{<br />
return (string)evtHandleTable[paramlist];<br />
}<br />
<br />
string evtHandlerName = GetClassName() + "EventHandler";<br />
for (int i = 1; (evtHandleTable.ContainsValue(evtHandlerName)); i++)<br />
{<br />
evtHandlerName = GetClassName() + "EventHandler" + i.ToString();<br />
}<br />
<br />
evtHandleTable.Add(paramlist, evtHandlerName);<br />
<br />
return evtHandlerName;<br />
}<br />
<br />
public void WriteDelegates()<br />
{<br />
Writeline("// Delegates");<br />
foreach (string paramlist in evtHandleTable.Keys)<br />
{<br />
Writeline("public delegate void " + evtHandleTable[paramlist] + paramlist + ";");<br />
}<br />
}<br />
<br />
public void Ident()<br />
{<br />
identStr += " ";<br />
}<br />
<br />
public void Unident()<br />
{<br />
identStr = identStr.Substring(0, identStr.Length - 4);<br />
}<br />
<br />
public void OpenBlock()<br />
{<br />
Writeline("{");<br />
Ident();<br />
}<br />
<br />
public void CloseBlock()<br />
{<br />
Unident();<br />
Writeline("}" + Environment.NewLine);<br />
}<br />
<br />
public void Writeline(string line)<br />
{<br />
output.Write(identStr);<br />
output.WriteLine(line);<br />
if (linePush.Count != 0)<br />
{<br />
foreach (string s in linePush)<br />
{<br />
output.Write(identStr);<br />
output.WriteLine(s);<br />
}<br />
linePush.Clear();<br />
}<br />
}<br />
<br />
public void PushLine(string line)<br />
{<br />
linePush.Add(line);<br />
}<br />
<br />
public string ConvertModifier(string mod)<br />
{<br />
switch (mod)<br />
{<br />
case "Overloads":<br />
return "";<br />
case "Overrides":<br />
return "override";<br />
case "Shared":<br />
return "static";<br />
case "Friend":<br />
return "internal";<br />
case "Shadows":<br />
return "new";<br />
case "ReadOnly":<br />
return "";<br />
case "WithEvents":<br />
return "";<br />
default:<br />
return mod.ToLower() + "";<br />
}<br />
}<br />
<br />
public string ConverteTipo(string tipo)<br />
{<br />
switch (tipo)<br />
{<br />
case "Integer":<br />
case "Int32":<br />
return "int";<br />
case "String":<br />
return "string";<br />
case "Object":<br />
return "object";<br />
case "Boolean":<br />
return "bool";<br />
case "Long":<br />
return "long";<br />
case "Single":<br />
return "float";<br />
case "Double":<br />
return "double";<br />
case "Short":<br />
return "short";<br />
case "Byte":<br />
return "byte";<br />
case "Char":<br />
return "char";<br />
case "Text":<br />
return "text";<br />
default:<br />
if (tipo.StartsWith("Me."))<br />
{<br />
tipo = "this." + tipo.Substring(3);<br />
}<br />
<br />
if (tipo.StartsWith("MyBase."))<br />
{<br />
tipo = "base." + tipo.Substring(7);<br />
}<br />
<br />
return tipo;<br />
}<br />
}<br />
<br />
public string ConverteString(string str)<br />
{<br />
if (str.IndexOf('\\') >= 0)<br />
return "@" + str;<br />
else<br />
return str;<br />
}<br />
<br />
public string ConverteLogicalOp(string str)<br />
{<br />
switch (str)<br />
{<br />
case "=":<br />
return " == ";<br />
case "<>":<br />
return " != ";<br />
default:<br />
return " " + str + " ";<br />
}<br />
}<br />
<br />
public string ConvertByX(string byx)<br />
{<br />
if (byx == "ByVal")<br />
return "";<br />
else<br />
return "ref ";<br />
}<br />
}<br />
}<br />
Peace all.
Try not! Do or do not, there is no try. - Master Yoda
|
|
|
|
|
thanks for providing this nice tool, i have years of doing asp, vbscript, vb.net but just now getting into C#. I have a windows .NET service i wanted to convert from VB to C#. all the tools take C# to VB but not other way around. thanks for sharing your expertise helping me get over the syntax differences in If/Then, Do/While, Do/Loop, and using them in conditional operators. This is my biggest challenge learning a new language now. Once I get C-syntax down, opportunities for other languages will be easier to grasp and just maybe OOP will even make sense.
|
|
|
|
|
It doesn't appear to handle the "Handles" statement to C# correctly
|
|
|
|
|
I have never used coco before, your article was a good intro on how to go about converting VB.Net to c#. It did not take long to add stuff for parsing VB properties, events and constructors.
Also fixes for "Do While", cascading classes in same VB file, support for "MyBase", "CType". Though it still does not handle array types gracefully.
Like you say, its not perfect, but certaining saves typing.
Great work.
Any way here is an improved VBNET.ATG source
<code>
using GBVB;
COMPILER VBNET
public Util util;
CHARACTERS
digit = "0123456789".
letter = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".
cr = "\r".
lf = "\n".
crlf = cr+lf.
space = " \t".
anyclose = ANY - "]".
stringChars = ANY - "\"".
TOKENS
number = digit { digit } [ "." digit { digit } ].
quotedString = "\"" { stringChars | "\"\"" } "\"".
identifier = (letter | "_") { letter | "_" | "." | digit }.
IGNORE space + crlf + "_"
COMMENTS FROM "'" TO cr
PRODUCTIONS
VBNET =
{ OptionStmt }
{ ImportStmt }
[ AttributeList ]
ClassStmt
.
ClassStmt
=
ClassGroup
{
ClassGroup
}
(.
util.Writeline("");
util.WriteDelegates();
.)
.
ClassGroup
=
(.
string modifier = "";
.)
[ ModifierGroup<out modifier> ]
TypeDeclaration<modifier>
.
ModifierGroup<out string modgroup> (.
string modifier;
modgroup = ""; .)
=
Modifier<out modifier> (. modgroup += modifier; .)
{
Modifier<out modifier> (. modgroup += modifier; .)
}
.
ImportStmt = (. string nmspc; .)
"Imports"
QualName<out nmspc> (. util.Writeline("using " + nmspc + ";"); .)
.
OptionStmt =
"Option"
(
"Explicit" ["On" | "Off"]
|
"Strict" ["On" | "Off"]
|
"Compare" ["Text" | "Binary"]
)
.
InheritanceDecl<out string decl> =
(. string typename; .)
"Inherits"
QualName<out typename> (. decl = " : " + typename; .)
.
ImplementsDecl<ref string decl> =
(. string typename; .)
"Implements"
QualName<out typename> (.
if (decl == "")
decl = " : " + typename;
else
decl += ", " + typename;
.)
{
","
QualName<out typename> (.
decl += ", " + typename;
.)
}
.
TypeDeclaration<string modifier>
=
(.
string bases = "";
string decl = modifier;
string typename;
.)
(
"Class" (. decl += "class "; .)
| "Structure" (. decl += "struct "; .)
)
QualName<out typename>
(.
decl += typename;
util.PushClassName(typename);
.)
[
InheritanceDecl<out bases>
]
[
ImplementsDecl<ref bases>
] (. decl += bases; .)
(.
util.Writeline(decl);
util.OpenBlock();
.)
{ MemberDeclaration }
"End" ("Class" | "Module") (.
util.CloseBlock();
util.PopClassName();
.)
.
ArithOp<out string op> =
(. op = ""; .)
(
("+" | "-" | "*" | "/") (. op = token.val; .)
| "\\" (. op = "/"; .)
| "Mod" (. op = "%"; .)
| "&" (. op = "+"; .)
| "Not" (. op = "!"; .)
| BoolOp<out op>
| LogicalOp<out op>
)
.
ArithExpr<out string exp> =
(. string op, exp2; .)
ArithOp<out op>
Expression<out exp2> (. exp = op + " " + exp2; .)
.
TypeOfExp<out string exp> =
(. string exp2, typespec; .)
"TypeOf"
QualName<out exp2>
"Is"
QualName<out typespec> (. exp = exp2 + " is " + typespec; .)
.
CTypeExp<out string exp> =
(.
string exp2, typespec, exp3;
.)
"CType"
"("
Expression<out exp2>
","
QualName<out typespec>
[
"(" (. typespec += "["; .)
ExpressionList<out exp3> (. typespec += exp3; .)
")" (. typespec += "]"; .)
]
")"
(.
exp = "((" + typespec + ")" + exp2 + ")";
.)
.
CObjExp<out string exp> =
(.
string exp2;
.)
"CObj"
"("
Expression<out exp2>
")"
(.
exp = "((object)" + exp2 + ")";
.)
.
ParentExp<out string exp> =
(.
string exp2;
.)
"("
Expression<out exp2>
")" (. exp = "(" + exp2 + ")"; .)
.
Expression<out string exp> =
(.
string parms = "";
string typename;
string exp2 = "";
exp = "";
.)
(
"True" (. exp = "true"; .)
|
"False" (. exp = "false"; .)
|
"Nothing" (. exp = "null"; .)
|
"Me" (. exp = "this"; .)
|
"MyBase" (. exp = "base"; .)
|
TypeOfExp<out exp>
|
CTypeExp<out exp>
|
CObjExp<out exp>
|
NumericConstant<out exp>
|
StringConstant<out exp>
|
ParentExp<out exp>
|
QualName<out exp>
[
(
"Is" "Nothing" (. exp += " == null"; .)
|
Callparms<out parms> (. exp += parms; .)
[
"."
Expression<out exp2> (. exp += "." + exp2; .)
]
)
]
|
"New"
QualName<out typename>
[
Callparms<out parms>
] (. exp = "new " + typename + parms; .)
)
[
ArithExpr<out exp2> (. exp += exp2; .)
]
.
LogicalOp<out string op>
=
("=" | "<" | ">" | ">=" | "<=" | "<>") (. op = util.ConverteLogicalOp(token.val); .)
.
BoolOp<out string op>
=
(. op = ""; .)
(
"And" (. op = " && "; .)
|
"AndAlso" (. op = " && "; .)
|
"Or" (. op = " || "; .)
|
"OrElse" (. op = " || "; .)
)
.
NumericConstant<out string exp> =
number (. exp = token.val; .)
.
StringConstant<out string exp> =
quotedString (. exp = util.ConverteString(token.val); .)
.
ExpressionList<out string expList> =
(. string exp; .)
Expression<out exp> (. expList = exp; .)
{
"," (. expList += token.val + " "; .)
Expression<out exp> (. expList += exp; .)
}
.
Callparms<out string parms> =
(. string expList; .)
"(" (. parms = token.val; .)
[
ExpressionList<out expList> (. parms += expList; .)
]
")" (. parms += token.val; .)
[
"(" (. parms += "["; .)
ExpressionList<out expList> (. parms += expList; .)
")" (. parms += "]"; .)
]
.
AttribSpec<out string attspec> =
(.
string pl;
string typename;
.)
QualName<out typename> (. attspec = typename; .)
[
Callparms<out pl> (. attspec += pl; .)
]
.
AttributeList =
(. string attlist;
string attspec;
.)
"<"
AttribSpec<out attlist>
{
"," (. attlist += token.val; .)
AttribSpec<out attspec> (. attlist += attspec; .)
}
">"
(.
util.Writeline("[" + attlist + "]");
.)
.
Modifier<out string modifier> =
("Public" | "Private" | "Protected" | "Overrides" | "Shared" | "Friend" | "WithEvents" | "Overloads" | "Shadows" | "ReadOnly")
(.
modifier = util.ConvertModifier(token.val);
.)
.
MemberDeclaration =
(.
string modifier = "";
.)
[ AttributeList ]
[ ModifierGroup<out modifier> ]
(
InterfaceDeclaration<modifier>
|
TypeDeclaration<modifier>
|
EventDeclaration<modifier>
|
EnumDeclaration<modifier>
|
PropertyDeclaration<modifier>
|
SubDeclaration<modifier>
|
FunctionDeclaration<modifier>
|
ConstDeclaration<modifier>
|
FieldDeclaration<modifier>
|
BeginRegion
|
EndRegion
).
InterfaceDeclaration<string modifier>
=
"Interface"
identifier (.
util.Writeline(modifier + "interface " + token.val);
util.OpenBlock();
.)
{
SubHeader<""> | FunctionHeader<"">
}
"End" "Interface" (. util.CloseBlock(); .)
.
EnumDeclaration<string modifier>
=
(.
string constName;
string constValue;
.)
"Enum"
identifier (.
util.Writeline(modifier + " enum " + token.val);
util.OpenBlock();
.)
{
identifier (. constName = token.val; constValue = null; .)
[ "="
Expression<out constValue>
] (.
if (constValue == null)
util.Writeline(constName);
else
util.Writeline(constName + " = " + constValue);
.)
}
"End" "Enum" (. util.CloseBlock(); .)
.
BeginRegion =
"#Region"
quotedString (. util.Writeline("#region " + token.val); .)
.
EndRegion =
"#End"
"Region" (.
util.Writeline("#endregion");
util.Writeline("");
.)
.
ConstDeclaration<string modifier> = (. string decl; .)
"Const"
VarDeclaration<out decl> (. util.Writeline(modifier + "const " + decl + ";"); .)
.
FieldDeclaration<string modifier> = (. string decl; .)
VarDeclaration<out decl> (. util.Writeline(modifier + decl + ";"); .)
.
QualName<out string typename> =
identifier (. typename = util.ConverteTipo(token.val); .)
.
DeclQualName<out string typename> =
identifier (. typename = util.ConverteTipo(token.val); .)
[
"("
")" (. typename += "[]"; .)
]
.
VarDeclaration<out string declaration> =
(. string typename;
string varname;
string exp;
string dimensions = null;
bool bIsArray = false;
string parms = "";
declaration = "";
.)
QualName<out varname>
[
"("
[ExpressionList<out dimensions>]
")" (. bIsArray = true; .)
]
"As"
(
"New"
QualName<out typename>
[
Callparms<out parms>
] (.
declaration = typename + " " + varname + " = new " + typename + parms;
.)
|
QualName<out typename> (.
if (!bIsArray)
declaration = typename + " " + varname;
else
{
declaration = typename + "[] " + varname;
if (dimensions != null)
declaration += String.Format(" = new {0}[{1}]", typename, dimensions);
}
.)
)
[
"="
Expression<out exp> (. declaration += " = " + exp; .)
]
.
SubImplementsInterface =
(.
string lixo;
.)
"Implements"
QualName<out lixo>
.
Handles =
(.
string lixo;
.)
"Handles"
QualName<out lixo>
.
BaseNewStmt<out string exp>=
(.
string parms = "";
.)
"MyBase.New"
"("
[
ExpressionList<out parms>
]
")"
(.
exp = "base(" + parms + ")";
.)
.
MeNewStmt<out string exp>=
(.
string parms = "";
.)
"Me.New"
"("
[
ExpressionList<out parms>
]
")"
(.
exp = "this(" + parms + ")";
.)
.
CtorStmt<ref string exp>=
BaseNewStmt<out exp>
|
MeNewStmt<out exp>
.
CtorGroup<ref string exp>=
(.
string exp2 = "";
.)
CtorStmt<ref exp>
{
CtorStmt<ref exp2> (.
exp += ", ";
exp += exp2;
.)
}
.
SubHeader<string modifier> =
(.
string decl = modifier;
string paramList;
string bases = "";
.)
"Sub"
("New" (. decl += " " + util.GetClassName(); .)
| identifier (. decl += "void " + token.val; .))
[
ParameterList<out paramList> (. decl += paramList; .)
]
[
CtorGroup<ref bases> (.
if (bases != "")
decl += " : " + bases;
.)
]
(.
if (modifier == "") // In interface declaration?
util.Writeline(decl + ";");
else
util.Writeline(decl);
.)
[SubImplementsInterface]
[Handles]
.
SubDeclaration<string modifier> =
SubHeader<modifier> (. util.OpenBlock(); .)
[RoutineBody]
"End" "Sub" (. util.CloseBlock(); .)
.
EventDeclaration<string modifier> =
(.
string decl = modifier;
string paramList = "";
string evtname = "";
.)
"Event" (. decl += "event "; .)
identifier (. evtname = token.val; .)
ParameterList<out paramList> (.
decl += util.GetEvtHandlerName(paramList) + " " + evtname;
util.Writeline(decl + ";");
.)
.
RaiseEventStmt =
(.
string paramList = "";
string evtname = "";
.)
"RaiseEvent"
identifier (. evtname = token.val; .)
"("
ExpressionList<out paramList>
")"
(.
util.Writeline("if (" + evtname + " != null)");
util.OpenBlock();
util.Writeline(evtname + "(" + paramList + ");");
util.CloseBlock();
.)
.
PropertyHeader<string modifier> =
(. string funcName;
string paramList = "";
string returnType;
.)
"Property"
identifier (. funcName = token.val; .)
[ ParameterList<out paramList> ]
"As"
DeclQualName<out returnType> (.
util.Writeline(modifier + " " + returnType + " " + funcName);
.)
.
PropertyGet =
"Get" (.
util.Writeline("get");
util.OpenBlock();
.)
[RoutineBody]
"End" "Get" (. util.CloseBlock(); .)
.
PropertySet = (. string paramList = ""; .)
"Set"
[
ParameterList<out paramList>
]
(.
util.Writeline("set");
util.OpenBlock();
.)
[RoutineBody]
"End" "Set" (. util.CloseBlock(); .)
.
PropertyDeclaration<string modifier> =
PropertyHeader<modifier> (. util.OpenBlock(); .)
PropertyBody
"End" "Property" (. util.CloseBlock(); .)
.
PropertyBody =
PropertyStmt { PropertyStmt }
.
PropertyStmt =
PropertyGet
|
PropertySet
.
FunctionHeader<string modifier> =
(. string funcName;
string paramList = "";
string returnType;
.)
"Function"
identifier (. funcName = token.val; .)
[ ParameterList<out paramList> ]
"As"
DeclQualName<out returnType> (.
util.Writeline(modifier + returnType + " " + funcName + paramList);
.)
[SubImplementsInterface]
[Handles]
.
FunctionDeclaration<string modifier> =
FunctionHeader<modifier> (. util.OpenBlock(); .)
[RoutineBody]
"End" "Function" (. util.CloseBlock(); .)
.
RoutineBody =
RoutineStmt { RoutineStmt }.
RoutineStmt =
AssignCall
|
SyncLockStmt
|
ThrowStmt
|
DoWhileStmt
|
ExitStmt
|
WhileStmt
|
CallStmt
|
SelectCase
|
ForStmt
|
IfStmt
|
TryCatch
|
ReturnStmt
|
LocalDeclaration
|
RaiseEventStmt
.
SyncLockStmt =
(. string exp; .)
"SyncLock"
Expression<out exp> (.
util.Writeline("lock (" + exp + ")");
util.OpenBlock();
.)
[RoutineBody]
"End" "SyncLock" (. util.CloseBlock(); .)
.
ThrowStmt =
(. string exp; .)
"Throw"
Expression<out exp> (. util.Writeline("throw " + exp + ";"); .)
.
DoWhileStmt =
(. string exp; .)
"Do"
(
"While" Expression<out exp> (.
util.Writeline("while (" + exp + ")");
util.OpenBlock();
.)
|
(.
util.Writeline("do");
util.OpenBlock();
.)
)
RoutineBody
"Loop"
(
"While" Expression<out exp> (.
util.CloseBlock();
util.Writeline("while (" + exp + ")");
.)
|
"Until" Expression<out exp> (.
util.CloseBlock();
util.Writeline("while (!(" + exp + "))");
.)
|
(.
util.CloseBlock();
.)
)
.
ExitStmt =
"Exit"
("For" | "While" | "Do") (. util.Writeline("break;"); .)
.
WhileStmt =
(. string exp; .)
"While"
Expression<out exp> (.
util.Writeline("while (" + exp + ")");
util.OpenBlock();
.)
[RoutineBody]
"End" "While" (. util.CloseBlock(); .)
.
ForVar =
(.
string loopvar;
string expIni;
string expEnd;
string stepExp;
string stepCS;
.)
QualName<out loopvar> (. stepCS = loopvar + "++"; .)
"="
Expression<out expIni>
"To"
Expression<out expEnd>
[
"Step"
Expression<out stepExp> (. stepCS = loopvar + " += " + stepExp; .)
] (.
util.Writeline(string.Format("for ({0}={1}; {0} <= {2}; {3})", loopvar, expIni, expEnd, stepCS));
util.OpenBlock();
.)
RoutineBody
"Next" [identifier] (.
util.CloseBlock();
.)
.
ForEach =
(.
string loopvar;
string expIni;
.)
"Each"
QualName<out loopvar>
"In"
Expression<out expIni>
(.
util.Writeline(string.Format("foreach ({0} in {1})", loopvar, expIni));
util.OpenBlock();
.)
RoutineBody
"Next" [identifier] (.
util.CloseBlock();
.)
.
ForStmt =
"For"
(
ForVar
|
ForEach
)
.
CallStmt =
(.
string funcname;
string parms = "";
.)
"Call"
QualName<out funcname>
[
Callparms<out parms>
] (. util.Writeline(funcname + parms + ";"); .)
.
ReturnStmt =
(. string exp; .)
"Return"
Expression<out exp> (. util.Writeline("return " + exp + ";"); .)
.
TryCatch =
(. string varname = "Exception"; .)
"Try" (.
util.Writeline("try");
util.OpenBlock();
.)
RoutineBody
[
"Catch"
[
VarDeclaration<out varname>
] (.
util.CloseBlock();
util.Writeline("catch (" + varname + ")");
util.OpenBlock();
.)
[RoutineBody]
]
[
"Finally" (.
util.CloseBlock();
util.Writeline("finally");
util.OpenBlock();
.)
RoutineBody
]
"End" "Try" (.
util.CloseBlock();
.)
.
SelectCase =
(. string exp; .)
"Select" "Case"
Expression<out exp>
(.
util.Writeline("switch (" + exp + ")");
util.OpenBlock();
.)
CaseStmts
"End" "Select" (. util.CloseBlock(); .)
.
CaseStmt =
(. string exp; .)
"Case"
(
"Else" (.
util.Writeline("default:");
util.Ident();
.)
|
Expression<out exp> (.
util.Writeline("case " + exp + ":");
util.Ident();
.)
{
","
Expression<out exp> (.
util.Unident();
util.Writeline("case " + exp + ":");
util.Ident();
.)
}
)
RoutineBody (.
util.Unident();
.)
.
CaseStmts =
CaseStmt
{ CaseStmt }
.
ElseStmt =
(. string exp; .)
("Else" (.
util.CloseBlock();
util.Writeline("else");
util.OpenBlock();
.)
RoutineBody
|
"ElseIf"
Expression<out exp>
"Then" (. util.CloseBlock();
util.Writeline("else if (" + exp + ")");
util.OpenBlock();
.)
RoutineBody
[ElseStmt]
)
.
IfStmt =
(. string exp; .)
"If"
Expression<out exp>
"Then" (.
util.Writeline("if (" + exp + ")");
util.OpenBlock();
.)
RoutineBody
[ElseStmt]
"End" "If" (.
util.CloseBlock();
.)
.
LeftAssign<out string call> =
(. string typename, pl, call2; .)
QualName<out typename> (. call = typename; .)
[
Callparms<out pl> (. call += pl; .)
[
"."
LeftAssign<out call2> (. call += "." + call2; .)
]
]
.
AssignCall =
(. string call;
string operation = "";
string rvalue = null;
.)
LeftAssign<out call>
[
[
"+" | "-" | "*" | "/" | "&" (. operation = token.val; .)
]
"="
Expression<out rvalue>
] (.
if (rvalue != null)
util.Writeline(call + " " + operation + "= " + rvalue + ";");
else
util.Writeline(call + ";");
.)
.
LocalDeclaration =
(.
string decl;
string constant = "";
.)
(
"Dim"
|
"Const" (. constant = "const "; .)
)
VarDeclaration<out decl> (. util.Writeline(constant + decl + ";"); .)
{ ","
VarDeclaration<out decl> (. util.Writeline(constant + decl + ";"); .)
}
.
ParameterList<out string paramList> =
(. string decl; .)
"(" (. paramList = token.val; .)
[
ParameterDeclaration<out decl> (. paramList += decl; .)
{
"," (. paramList += token.val + " "; .)
ParameterDeclaration<out decl> (. paramList += decl; .)
}
]
")" (. paramList += token.val; .)
.
ParameterDeclaration<out string declaration> =
(. string decl; .)
["ByVal" | "ByRef"] (. declaration = util.ConvertByX(token.val); .)
VarDeclaration<out decl> (. declaration += decl; .)
.
END VBNET.
</code>
And here are is the util.cs file
<code>
using VBNET;
using System;
using System.IO;
using System.Collections.Specialized;
namespace GBVB
{
public class Util
{
string identStr = "";
public TextWriter output;
StringCollection linePush = new StringCollection();
System.Collections.Stack stackClassname = new System.Collections.Stack();
System.Collections.Hashtable evtHandleTable = new System.Collections.Hashtable();
public void PushClassName(string classname)
{
stackClassname.Push(classname);
}
public void PopClassName()
{
stackClassname.Pop();
}
public string GetClassName()
{
object classname = stackClassname.Peek();
if (classname == null)
return "";
return (string)classname;
}
public string GetEvtHandlerName(string paramlist)
{
if (evtHandleTable.ContainsKey(paramlist))
{
return (string)evtHandleTable[paramlist];
}
string evtHandlerName = GetClassName() + "EventHandler";
for (int i = 1; (evtHandleTable.ContainsValue(evtHandlerName)); i++)
{
evtHandlerName = GetClassName() + "EventHandler" + i.ToString();
}
evtHandleTable.Add(paramlist, evtHandlerName);
return evtHandlerName;
}
public void WriteDelegates()
{
Writeline("// Delegates");
foreach (string paramlist in evtHandleTable.Keys)
{
Writeline("public delegate void " + evtHandleTable[paramlist] + paramlist + ";");
}
}
public void Ident()
{
identStr += " ";
}
public void Unident()
{
identStr = identStr.Substring(0, identStr.Length - 4);
}
public void OpenBlock()
{
Writeline("{");
Ident();
}
public void CloseBlock()
{
Unident();
Writeline("}" + Environment.NewLine);
}
public void Writeline(string line)
{
output.Write(identStr);
output.WriteLine(line);
if (linePush.Count != 0)
{
foreach (string s in linePush)
{
output.Write(identStr);
output.WriteLine(s);
}
linePush.Clear();
}
}
public void PushLine(string line)
{
linePush.Add(line);
}
public string ConvertModifier(string mod)
{
switch (mod)
{
case "Overloads":
return "";
case "Overrides":
return "override ";
case "Shared":
return "static";
case "Friend":
return "internal";
case "Shadows":
return "new";
case "ReadOnly":
return "";
case "WithEvents":
return "";
default:
return mod.ToLower() + " ";
}
}
public string ConverteTipo(string tipo)
{
switch (tipo)
{
case "Integer":
return "int";
case "String":
return "string";
case "Object":
return "object";
case "Boolean":
return "bool";
case "Long":
return "long";
case "Single":
return "float";
case "Double":
return "double";
case "Short":
return "short";
case "Byte":
return "byte";
case "Char":
return "char";
case "Text":
return "text";
default:
if (tipo.StartsWith("Me."))
{
tipo = "this." + tipo.Substring(3);
}
if (tipo.StartsWith("MyBase."))
{
tipo = "base." + tipo.Substring(7);
}
return tipo;
}
}
public string ConverteString(string str)
{
if (str.IndexOf('\\') >= 0)
return "@" + str;
else
return str;
}
public string ConverteLogicalOp(string str)
{
switch (str)
{
case "=":
return " == ";
case "<>":
return " != ";
default:
return " " + str + " ";
}
}
public string ConvertByX(string byx)
{
if (byx == "ByVal")
return "";
else
return "ref ";
}
}
}
</code>
|
|
|
|
|