Question converting C# code to VB.net

I

Ivan

I need to do custom column type for DataGridView and msdn has sample but
only for c#

I have problem converting this piece of code:

class MaskedTextBoxCell : DataGridViewTextBoxCell
{
private string mask;
private char promptChar;
private DataGridViewTriState includePrompt;
private DataGridViewTriState includeLiterals;
private Type validatingType;

public MaskedTextBoxCell() : base()
{
this.mask = "";
this.promptChar = '_';
this.includePrompt = DataGridViewTriState.NotSet;
this.includeLiterals = DataGridViewTriState.NotSet;
this.validatingType = typeof(string);
}


How do I write:
public MaskedTextBoxCell() : base()
in VB ?

Thank you,
Ivan
 
T

Tom Shelton

I need to do custom column type for DataGridView and msdn has sample but
only for c#

I have problem converting this piece of code:

class MaskedTextBoxCell : DataGridViewTextBoxCell
{
private string mask;
private char promptChar;
private DataGridViewTriState includePrompt;
private DataGridViewTriState includeLiterals;
private Type validatingType;

public MaskedTextBoxCell() : base()
{
this.mask = "";
this.promptChar = '_';
this.includePrompt = DataGridViewTriState.NotSet;
this.includeLiterals = DataGridViewTriState.NotSet;
this.validatingType = typeof(string);
}


How do I write:
public MaskedTextBoxCell() : base()
in VB ?

You don't have to. In fact, you don't have to in C# either - the call to the
base class constructor is automatically done for you. But, if you feel the
need to be overly explicit, as the code above, then the equivalent would be:

Public Sub New ()
MyBase.New()
' do you init stuff
End Sub
 
L

Lloyd Sheen

Ivan said:
I need to do custom column type for DataGridView and msdn has sample but
only for c#

I have problem converting this piece of code:

class MaskedTextBoxCell : DataGridViewTextBoxCell
{
private string mask;
private char promptChar;
private DataGridViewTriState includePrompt;
private DataGridViewTriState includeLiterals;
private Type validatingType;

public MaskedTextBoxCell() : base()
{
this.mask = "";
this.promptChar = '_';
this.includePrompt = DataGridViewTriState.NotSet;
this.includeLiterals = DataGridViewTriState.NotSet;
this.validatingType = typeof(string);
}


How do I write:
public MaskedTextBoxCell() : base()
in VB ?

Thank you,
Ivan

Try this:

Public Sub New()
MyBase.New()
Me.mask = ""
Me.promptChar = "_"c
Me.includePrompt = DataGridViewTriState.NotSet
Me.includeLiterals = DataGridViewTriState.NotSet
Me.validatingType = GetType(String)
End Sub

LS
 
T

Tom Dacon

While this doesn't address the instance of your problem, it does address the
class.

Get a book on C# and learn the language. It shouldn't take more than about
three days. Then you'll never have to ask other people who know both of them
to solve your problems for you.

To you C# guys who come here to ask for help in interpreting VB code, do the
same thing with VB: take a few days to learn it and solve your own problems.

Tom Dacon
Dacon Software Consulting
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top