473,385 Members | 1,372 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Please help...from C# to VB

Hi :

I'm new to VB and C#, can someone help me to convert this code to VB

1. The following code, what is the 'this' means ?
public object this [int index]
{
get {return ((IDataRecord)myObj)[index];}
}

2. What is the different using 'this' and 'base' ?
public class MyClass
{
public MyClass(int Param1)
: base (Param1, 123)
{
}
// the above block can i change to ..??
//public MyClass(int Param1)
//{
// base.MyClass(Param1, 123)

// }

public MyClass(int Param1, int Param2)
: this (Param1)
{
...
}
}
Is this conversion correct ?

public class MyClass
public sub New(Param1 AS Integer)
MyBase.New(Param1, 123) ' or MyClass.New(Param1, 123) ???
end sub

public sub New(Param1 AS Integer, Param2 AS Integer)
Me.New(Param1, 123)
...
end sub
end class
Thanks
JCVoon
Nov 21 '05 #1
6 1267
Hi JC Voon,

the next link will be vey interesting for you:
http://www.kamalpatel.net/ConvertCSharp2VB.aspx

Kind Regards,

Jorge Serrano PĂ©rez
MVP VB.NET

"JC Voon" wrote:
Hi :

I'm new to VB and C#, can someone help me to convert this code to VB

1. The following code, what is the 'this' means ?
public object this [int index]
{
get {return ((IDataRecord)myObj)[index];}
}

2. What is the different using 'this' and 'base' ?
public class MyClass
{
public MyClass(int Param1)
: base (Param1, 123)
{
}
// the above block can i change to ..??
//public MyClass(int Param1)
//{
// base.MyClass(Param1, 123)

// }

public MyClass(int Param1, int Param2)
: this (Param1)
{
...
}
}
Is this conversion correct ?

public class MyClass
public sub New(Param1 AS Integer)
MyBase.New(Param1, 123) ' or MyClass.New(Param1, 123) ???
end sub

public sub New(Param1 AS Integer, Param2 AS Integer)
Me.New(Param1, 123)
...
end sub
end class
Thanks
JCVoon

Nov 21 '05 #2
1. It refers to the indexer implementation of a class (also known as default
property). For more info on this:
http://msdn.microsoft.com/library/en...asp?frame=true

2. MyClass is a keyword in VB .NET, so it can't be used for class names.
Also, this class doesn't derive from any class that takes two parametes for
its constructor, so MyBase.New(Param1, 123) will not work. Finally, the
constructor cannot call itself (Me.New(Param1, 123))

HTH.

"JC Voon" <jc*******@yahoo.com> wrote in message
news:41***************@msnews.microsoft.com...
Hi :

I'm new to VB and C#, can someone help me to convert this code to VB

1. The following code, what is the 'this' means ?
public object this [int index]
{
get {return ((IDataRecord)myObj)[index];}
}

2. What is the different using 'this' and 'base' ?
public class MyClass
{
public MyClass(int Param1)
: base (Param1, 123)
{
}
// the above block can i change to ..??
//public MyClass(int Param1)
//{
// base.MyClass(Param1, 123)

// }

public MyClass(int Param1, int Param2)
: this (Param1)
{
...
}
}
Is this conversion correct ?

public class MyClass
public sub New(Param1 AS Integer)
MyBase.New(Param1, 123) ' or MyClass.New(Param1, 123) ???
end sub

public sub New(Param1 AS Integer, Param2 AS Integer)
Me.New(Param1, 123)
...
end sub
end class
Thanks
JCVoon
Nov 21 '05 #3
Jorge,

"Jorge Serrano [MVP VB]"
<NO*******************@NOQUIEROSPAMportalvbNOSPAM. com.NOQUIEROSPAM> schrieb:
the next link will be vey interesting for you:
http://www.kamalpatel.net/ConvertCSharp2VB.aspx


ACK. Some more converters:

Converting code between .NET programming languages
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=languageconverters&lang=en>

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 21 '05 #4
Thanks a million Herfried,

this is a better link with more information.

Thanks a lot!

Jorge
"Herfried K. Wagner [MVP]" wrote:
Jorge,

"Jorge Serrano [MVP VB]"
<NO*******************@NOQUIEROSPAMportalvbNOSPAM. com.NOQUIEROSPAM> schrieb:
the next link will be vey interesting for you:
http://www.kamalpatel.net/ConvertCSharp2VB.aspx


ACK. Some more converters:

Converting code between .NET programming languages
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=languageconverters&lang=en>

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 21 '05 #5
Shiva, Jorge Serrano:

Thanks for the reply.

I use the converter from
http://www.aspalliance.com/aldotnet/...translate.aspx

The following C# code.....

public object this [int index] // Indexer declaration
{
get {return ....;}
}
After convert to VB.....

Default Public ReadOnly Property Item(ByVal index As Integer) As
Object
Get
Return ...
End Get
End Property

The 'this' keyword in C# is convert to 'Item', but some of the
converter (can't remember which one) convert to 'Me' and some of it
convert to 'Blubber', doest it means i can simply put any name i like
?

Thanks

Regards
JCVoon
Nov 21 '05 #6
I feel 'Item' (with Default keyword) is more appropriate (thats what being
used in .NET base class libaries also). But, practically it can be any name
but not Me because its a keyword in Visual Basic .NET.

HTH

"JC Voon" <jc*******@yahoo.com> wrote in message
news:41**************@msnews.microsoft.com...
Shiva, Jorge Serrano:

Thanks for the reply.

I use the converter from
http://www.aspalliance.com/aldotnet/...translate.aspx

The following C# code.....

public object this [int index] // Indexer declaration
{
get {return ....;}
}
After convert to VB.....

Default Public ReadOnly Property Item(ByVal index As Integer) As
Object
Get
Return ...
End Get
End Property

The 'this' keyword in C# is convert to 'Item', but some of the
converter (can't remember which one) convert to 'Me' and some of it
convert to 'Blubber', doest it means i can simply put any name i like
?

Thanks

Regards
JCVoon
Nov 21 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: duikboot | last post by:
Hi all, I'm trying to export a view tables from a Oracle database to a Mysql database. I create insert statements (they look alright), but it all goes wrong when I try to execute them in Mysql,...
1
by: Az Tech | last post by:
Hi people, (Sorry for the somewhat long post). I request some of the people on this group who have good experience using object-orientation in the field, to please give some good ideas for...
2
by: m3ckon | last post by:
Hi there, had to rush some sql and am now going back to it due to a slow db performance. I have a db for sales leads and have created 3 views based on the data I need to produce. However one...
7
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: {////<<head> <title>IIBO Submit Page</title>...
7
by: tyler_durden | last post by:
thanks a lot for all your help..I'm really appreciated... with all the help I've been getting in forums I've been able to continue my program and it's almost done, but I'm having a big problem that...
23
by: Jason | last post by:
Hi, I was wondering if any could point me to an example or give me ideas on how to dynamically create a form based on a database table? So, I would have a table designed to tell my application...
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
1
PEB
by: PEB | last post by:
POSTING GUIDELINES Please follow these guidelines when posting questions Post your question in a relevant forum Do NOT PM questions to individual experts - This is not fair on them and...
0
by: 2Barter.net | last post by:
newsmail@reuters.uk.ed10.net Fwd: Money for New Orleans, AL & GA Inbox Reply Reply to all Forward Print Add 2Barter.net to Contacts list Delete this message Report phishing Show original
6
by: jenipriya | last post by:
Hi all... its very urgent.. please........i m a beginner in oracle.... Anyone please help me wit dese codes i hv tried... and correct the errors... The table structures i hav Employee (EmpID,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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

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