Tom Johnson

"string.right"

vb.net: {Strings.Left(full_name, 2), Strings.Right(full_name, full_name.Length - 3)}
converts to
c#: { full_name.Substring(0, 2), full_name.Substring(full_name.Length - 3) }

Strings.Left is correct.
Strings.Right is WRONG!

vb.net: Strings.Right(full_name, full_name.Length - 3)
should convert to:
c#: full_name.Substring(3)
should return all but first three chars of string
Problem by Tom Johnson Status: Not Done Comments: 0 Last update: 2016-01-03T09:38:59 by Tom Johnson
0
Sabata Mereeotlhe

Math and String functions

I am currently working on a engineering piece of software and convert old vb6 to c# 4.6

1. I have had quite a few times that I needed to add Math. in front of the converted c# code eg.

Log => Math.Log

This might be the case with other Math functions

2. I have had to change the statement of counting the length of a string and other string functions as follows

Len(string) => string.Length
Mid(string, int, int) => string.Substring(int, int)

This could be the case with other string functions
Feedback by Sabata Mereeotlhe Status: Not Done Comments: 0 Last update: 2015-10-27T10:27:13 by Sabata Mereeotlhe
0
Antonio Lopes

Check EventHandler event is null (nothing)

C# version
-----------------------------------------
public event EventHandler SendToPLC;
private void barcodeTextBox_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == '\r')
{
if (SendToPLC != null)
{
SendToPLC(sender, e);
e.Handled = true;
}
}
}
VB.NET version
-----------------
Public Event SendToPLC As EventHandler
Private Sub barcodeTextBox_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs)
If e.KeyChar = ControlChars.Cr Then
'If SendToPLC IsNot Nothing Then
'MISSING "EVENT" on end of Event Name. !@#@@^#%. WHY THIS?
If SendToPLCEvent IsNot Nothing Then
RaiseEvent SendToPLC(sender, e)
e.Handled = True
End If
End If
End Sub

Very thanks by Free converter

antonio
Feedback by Antonio Lopes Status: Not Done Comments: 0 Last update: 2015-10-02T06:45:14 by Antonio Lopes
0
Maury Markowitz

Some upgrades for the VS code convertor

I converted several hundred thousand lines of code from VS to C# using the online tool - glutton for punishment I guess! I found a couple of problems that I think might be easy to fix that would eliminate 70% of the problems I saw.

1) In VS you can have functions with no inputs - subs. There are many common ones, like .ToString(), .ToUpper(), etc. VS demands you leave off the parens in these cases, but C# demands them. The converter fails to notice these and so I have to manually add "()" to thousands of lines of code.

2) VS uses parens for enumerators, like MyList(1). C# uses braces for enumerators, like MyList[1]. The converter doesn't convert these. VERY annoying!

3) The convertor ignores #if #else #endif, and so it sees both halfs of the code. So if you have an End Sub in an if block, for instance, it can't convert it because it sees two End Subs. Suggest commenting out the one that is not active, or if that's not obvious, leaving the first active and commenting out all the ELSE side of things.
Feedback by Maury Markowitz Status: Not Done Comments: 0 Last update: 2015-09-17T15:58:36 by Maury Markowitz
0
อมร อุ่นจิตต์วรรธนะ

watcher.changed += new filesystemeventhandler(addressof watcher_changedcreationtime) ====>> addhandler watcher.changed, new filesystemeventhandler(addressof watcher_changedcreationtime)

I'm tried convert from C# to vb.net
Link: http://www.codeproject.com/Articles/58740/FileSystemWatcher-Pure-Chaos-Part-of

in file Watcher.cs

VB.NET (VS2013, .NET4.0) C# to vb.net error is:

watcher.changed += new filesystemeventhandler(addressof watcher_changedcreationtime)

VB.NET (VS2013, .NET4.0) correct is:

addhandler watcher.changed, new filesystemeventhandler(addressof watcher_changedcreationtime)
Problem by อมร อุ่นจิตต์วรรธนะ Status: Not Done Comments: 0 Last update: 2015-09-17T05:58:02 by อมร อุ่นจิตต์วรรธนะ
0
El Capitan

-- line 1 col 1: eof expected

when converting VB to c#I am getting error
-- line 1 col 1: EOF expected
Feedback by El Capitan Status: Not Done Comments: 3 Last update: 2015-08-31T11:12:42 by Howard Woods
1
Dolf Meijer

Error converting VB AND / OR operators to C#

When converting a VB IF-THEN statement, sometimes the conditional AND and OR operators are converted to '&' and '|' respectively. These are bit-operators, not boolean operators. Expecially when the exact type cannot be determined, the bit opertors are favoured over the move obvious '&&' and ||' boolean operators.
Example:
VB:
If x.boolField And y.Length > 1 Then
' do something
End If
C#:
if (x.boolField & y.Length > 1) {
// do something
}
Problem by Dolf Meijer Status: Not Done Comments: 0 Last update: 2015-07-30T10:50:58 by Dolf Meijer
0
M Roberts

vbNullString

vbNullString doesn't get translated to null
Problem by M Roberts Status: Not Done Comments: 0 Last update: 2015-07-16T18:27:30 by M Roberts
0
Darkie Doom

Use of array conversion VB.net -> C#

Hey please correct this issue:
When I convert a code from vb.net to c#.net, the converter won't convert the usage of arrays corretly:
vb: messagebox(mystrarray(0))
the convertet text: messagebox.show(mystrarray(0))
But the right conversation would be:
messagebox.show(mystrarray[0])
Thank you :)
Feature Request by Darkie Doom Status: Not Done Comments: 0 Last update: 2015-06-27T19:49:01 by Darkie Doom
0
Tim Hittesdorf

Structure to struct

Public Structure Oid
Public Shared Property RuntimeMac As String = "1.3.6.1.4.1.12394.1.1.1.10.0"
Public Shared Property UnitMac As String = "1.3.6.1.4.1.12394.1.1.1.8.0"
End Structure

gets converted to

public struct Oid
{
public static string RuntimeMac { get; set; }
public static string UnitMac { get; set; }
}

instead of

public struct Oid
{
public const string
RuntimeMac = "1.3.6.1.4.1.12394.1.1.1.10.0",
UnitMac = "1.3.6.1.4.1.12394.1.1.1.8.0";
}
Feedback by Tim Hittesdorf Status: Not Done Comments: 0 Last update: 2015-06-19T14:25:46 by Tim Hittesdorf
0
Displaying items 21 - 30 of 71