473,396 Members | 1,846 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,396 software developers and data experts.

Converting C# to VB

Could someone help me translating the following C# code to VB? Is there
a different newsgroup where it would be better to post this?
[ListBindable(false)]
public class CategoriesInfo : CollectionBase {
static CategoriesInfo instance;
// create the static instance of the class
static CategoriesInfo() {
instance = new CategoriesInfo();
}
public CategoryInfo this[int index] { get { return List[index] as
CategoryInfo; } }
public CategoryInfo this[string name] {
get {
for(int i = 0; i < Count; i ++)
if(name.ToUpper() == this[i].Name.ToUpper())
return this[i];
return null;
}
}

// Register the category in the system
public static void Add(string name, int imageIndex) {
CategoryInfo item = new CategoryInfo(name, imageIndex);
instance.List.Add(item);
}
public static void Add(string name) {
CategoriesInfo.Add(name, -1);
}
public static CategoriesInfo Instance { get { return instance; } }
}

*** Sent via Developersdex http://www.developersdex.com ***
May 27 '06 #1
4 1349
<ListBindable(False)> _
Public Class CategoriesInfo
Inherits CollectionBase
Shared m_instance As CategoriesInfo
' create the static instance of the class
Private Shared Sub New()
m_instance = New CategoriesInfo()
End Sub
Public Default ReadOnly Property ConvertedIndexer(ByVal index As Integer) As
CategoryInfo
Get
Return TryCast(List(index), CategoryInfo)
End Get
End Property
Public Default ReadOnly Property ConvertedIndexer(ByVal name As String) As
CategoryInfo
Get
For i As Integer = 0 To Count - 1
If name.ToUpper() = Me(i).Name.ToUpper() Then
Return Me(i)
End If
Next
Return Nothing
End Get
End Property
' Register the category in the system
Public Shared Sub Add(ByVal name As String, ByVal imageIndex As Integer)
Dim item As CategoryInfo = New CategoryInfo(name, imageIndex)
m_instance.List.Add(item)
End Sub
Public Shared Sub Add(ByVal name As String)
CategoriesInfo.Add(name, - 1)
End Sub
Public Shared ReadOnly Property Instance() As CategoriesInfo
Get
Return m_instance
End Get
End Property
End Class
May 27 '06 #2
The other post was mostly correct, but there were two mistakes: 1. the
constructor is not private and 2. the indexers should be named the standard
"Item".
Our Instant VB C# to VB converter produces:
<ListBindable(False)> _
Public Class CategoriesInfo : Inherits CollectionBase
Private Shared instance_Renamed As CategoriesInfo
' create the static instance of the class
Shared Sub New()
instance_Renamed = New CategoriesInfo()
End Sub
Public ReadOnly Default Property Item(ByVal index As Integer) As
CategoryInfo
Get
Return TryCast(List(index), CategoryInfo)
End Get
End Property
Public ReadOnly Default Property Item(ByVal name As String) As CategoryInfo
Get
For i As Integer = 0 To Count - 1
If name.ToUpper() = Me(i).Name.ToUpper() Then
Return Me(i)
End If
Next i
Return Nothing
End Get
End Property

' Register the category in the system
Public Shared Sub Add(ByVal name As String, ByVal imageIndex As Integer)
Dim item As CategoryInfo = New CategoryInfo(name, imageIndex)
instance_Renamed.List.Add(item)
End Sub
Public Shared Sub Add(ByVal name As String)
CategoriesInfo.Add(name, -1)
End Sub
Public Shared ReadOnly Property Instance() As CategoriesInfo
Get
Return instance_Renamed
End Get
End Property
End Class

--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C# to C++ converter & VB to C++ converter
Instant J#: VB to J# converter

"Bob Roy" wrote:
Could someone help me translating the following C# code to VB? Is there
a different newsgroup where it would be better to post this?

[ListBindable(false)]
public class CategoriesInfo : CollectionBase {
static CategoriesInfo instance;
// create the static instance of the class
static CategoriesInfo() {
instance = new CategoriesInfo();
}
public CategoryInfo this[int index] { get { return List[index] as
CategoryInfo; } }
public CategoryInfo this[string name] {
get {
for(int i = 0; i < Count; i ++)
if(name.ToUpper() == this[i].Name.ToUpper())
return this[i];
return null;
}
}

// Register the category in the system
public static void Add(string name, int imageIndex) {
CategoryInfo item = new CategoryInfo(name, imageIndex);
instance.List.Add(item);
}
public static void Add(string name) {
CategoriesInfo.Add(name, -1);
}
public static CategoriesInfo Instance { get { return instance; } }
}

*** Sent via Developersdex http://www.developersdex.com ***

May 27 '06 #3
Convert your code here:
http://www.kamalpatel.net/ConvertCSharp2VB.aspx
http://www.ragingsmurf.com/vbcsharpconverter.aspx
http://authors.aspalliance.com/aldot...translate.aspx

Have fun!!!
chanmm
"Bob Roy" <br**@omegasoftwareinc.com> wrote in message
news:e3**************@TK2MSFTNGP02.phx.gbl...
Could someone help me translating the following C# code to VB? Is there
a different newsgroup where it would be better to post this?

[ListBindable(false)]
public class CategoriesInfo : CollectionBase {
static CategoriesInfo instance;
// create the static instance of the class
static CategoriesInfo() {
instance = new CategoriesInfo();
}
public CategoryInfo this[int index] { get { return List[index] as
CategoryInfo; } }
public CategoryInfo this[string name] {
get {
for(int i = 0; i < Count; i ++)
if(name.ToUpper() == this[i].Name.ToUpper())
return this[i];
return null;
}
}

// Register the category in the system
public static void Add(string name, int imageIndex) {
CategoryInfo item = new CategoryInfo(name, imageIndex);
instance.List.Add(item);
}
public static void Add(string name) {
CategoriesInfo.Add(name, -1);
}
public static CategoriesInfo Instance { get { return instance; } }
}

*** Sent via Developersdex http://www.developersdex.com ***

May 27 '06 #4
If you tried the original poster's C# code in any of those converters (I just
did), you'd see that the output is unacceptable non-compilable code.
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C# to C++ converter & VB to C++ converter
Instant J#: VB to J# converter

"chanmm" wrote:
Convert your code here:
http://www.kamalpatel.net/ConvertCSharp2VB.aspx
http://www.ragingsmurf.com/vbcsharpconverter.aspx
http://authors.aspalliance.com/aldot...translate.aspx

Have fun!!!
chanmm
"Bob Roy" <br**@omegasoftwareinc.com> wrote in message
news:e3**************@TK2MSFTNGP02.phx.gbl...
Could someone help me translating the following C# code to VB? Is there
a different newsgroup where it would be better to post this?

[ListBindable(false)]
public class CategoriesInfo : CollectionBase {
static CategoriesInfo instance;
// create the static instance of the class
static CategoriesInfo() {
instance = new CategoriesInfo();
}
public CategoryInfo this[int index] { get { return List[index] as
CategoryInfo; } }
public CategoryInfo this[string name] {
get {
for(int i = 0; i < Count; i ++)
if(name.ToUpper() == this[i].Name.ToUpper())
return this[i];
return null;
}
}

// Register the category in the system
public static void Add(string name, int imageIndex) {
CategoryInfo item = new CategoryInfo(name, imageIndex);
instance.List.Add(item);
}
public static void Add(string name) {
CategoriesInfo.Add(name, -1);
}
public static CategoriesInfo Instance { get { return instance; } }
}

*** Sent via Developersdex http://www.developersdex.com ***


May 27 '06 #5

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

Similar topics

8
by: prabha | last post by:
Hello Everybody, I have to conert the word doc to multiple html files,according to the templates in the word doc. I had converted the word to xml.Also through Exsl ,had finished the multiple...
5
by: Robert | last post by:
I have a series of web applications (configured as separate applications) on a server. There is a main application at the root and then several virtual directories that are independant...
3
by: Mary | last post by:
Hi, Does anyone know of any software out there that would convert an application written in VBScript to either VB.NET or C#/C++ quite quickly for me, or will I have to re-write the application...
7
by: Tor Aadnevik | last post by:
Hi, I have a problem converting values from Single to double. eg. When the Single value 12.19 is converted to double, the result is 12.1899995803833. Anyone know how to avoid this? Regards...
2
by: shenanwei | last post by:
DB2 V8.2 on AIX, type II index is created. I see this from deadlock event monitor. 5) Deadlocked Connection ... Participant no.: 2 Lock wait start time: 09/18/2006 23:04:09.911774 .........
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.