Question

I'll start off by saying that everything I know about C# I've learned in the last few days researching how to convert a C# module to VB.Net 4.0.

The code below is a few select lines from the C# module that I'm converting to VB.Net. For the most part, it has been relatively simple and what I haven't been able to figure out, I've Googled and found an answer for. After about 10 hours of attempting to search for the answer(s) to the lines below, I finally came here looking for help.

As far as I can tell, the C# code creates a List of Integer, where the Integer is an array. The lines that I've included below that access that arrayed list.

My question is this: How can I convert this to VB.Net 4.0? or Can someone provide me with the working converted code?

Thanks in advance!

C# Code:

// mColumnPoint, mStartPoint, mEndPoint are all Integers
// Note that there is a mColumnPoint(int) and mColumnPoints(list) plural

private List<int[]> mColumnPoints;

mColumnPoints = new List<int[]>();

mColumnPoints.Add(new int[] { mStartPoint, mEndPoint });

for (int i = (int)mColumnPoints[mColumnPoint].GetValue(0);
   i < (int)mColumnPoints[mColumnPoint].GetValue(1); i++)
{
    // Stuff in for loop here
}
Was it helpful?

Solution

Well, It's an easy task:

            Dim list As List(Of Integer()) = New List(Of Integer())()
        list.Add(New Integer()() = { Class1.mStartPoint, Class1.mEndPoint })
        For i As Integer = CInt(list(Class1.mColumnPoint).GetValue(0))To CInt(list(Class1.mColumnPoint).GetValue(1)) - 1
        Next

I've used a great tool called "ILSpy", http://sourceforge.net/projects/sharpdevelop/files/ILSpy/2.0/ILSpy_Master_2.1.0.1603_RTW_Binaries.zip/download Simply build what you want using C# or vb.net then open that tool and browse for your *.exe or *.dll to see it in vb.net or c#, have fun :)

OTHER TIPS

  Module Module1

Structure segment
    Dim startingPoint As Integer
    Dim endingPoint As Integer
End Structure

Sub Main()

    Dim mStartPoint, mEndPoint, mColumnPoint As Integer

    Dim mColumnPoints As New ArrayList
    Dim nextSegment As segment

    mStartPoint = 1
    mEndPoint = 42
    mColumnPoint = 0  ' The first element in the array

    nextSegment.startingPoint = mStartPoint
    nextSegment.endingPoint = mEndPoint

    mColumnPoints.Add(nextSegment)

    Dim startValue As Integer = mColumnPoints(mColumnPoint).startingPoint
    Dim limit As Integer = mColumnPoints(mColumnPoint).endingPoint

    Dim i As Integer
    For i = startValue To limit
        ' do something
        Console.WriteLine("Cycle # " & i.ToString)
    Next

    Console.WriteLine("Done " & i.ToString)

End Sub

End Module
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top