Hi Friends,

There is one turn in my ASP.NET page where I have to use parsing 
technique. As I told that I'm a java developer and just now I 
switched to ASP.NET Technology. So could any one help me out to 
convert below given Java Code into VB.NET which I can use in my 
ASP.NET Pages.

******************* JAVA CODE ********************

public class Hello{

//*************************** display WorkExperience 
*********************

public String[][] displayWorkExperience(String WE)
{

int endindex =0;
int plusindex=0;
int count=0;
int i=0,c1=0,c2=0; String[] value = new String[6];
String[][] WorkExperience_Data = null;


try{

String str = WE;


while (str!=null)
{
        endindex = str.indexOf('$',0);
         break;
}//end

//Count plus

while(i<endindex){
        plusindex = str.indexOf('+',i);
        count++;
        i=plusindex;
        i++;
        }

i=0;


WorkExperience_Data = new String [count][6];

count=0;


        while(i<endindex){


        plusindex = str.indexOf('+',i);
        String s = str.substring(i,plusindex);



        for (int j=0;j<6;j++)
        {
                c1 = str.indexOf(',',c1);

                value[j]=str.substring(c2,c1);

                c1++;
                c2=c1;

        }


        WorkExperience_Data[count][0] = value[0];
        WorkExperience_Data[count][1] = value[1];
        WorkExperience_Data[count][2] = value[2];
        WorkExperience_Data[count][3] = value[3];
        WorkExperience_Data[count][4] = value[4];
        WorkExperience_Data[count][5] = value[5];
        
        count++;

        i=plusindex;
        c1=plusindex;
        c2=plusindex;

        c1++;
        c2++;
        i++;


        }

}
catch(Exception e){}

return WorkExperience_Data;
}

public static void main(String args[]){

        Hello n = new Hello();
        System.out.println("Hello, Its Working");
String WE = "Database Designer/Software Developer,11,2002,-,-
,Working as Database Designer/Software Developer at Intelligent 
Solutions Consultant and Still Working(on Contract),+IT 
Officer,08,2002,11,2002,Worked as IT Officer at Dr. Zai-u-ddin 
Medical University from Aug 2002 to Nov 2002,+$";
        String[][] WED = n.displayWorkExperience(WE);

        System.out.println(">>>" + WED.length);
        for(int k=0;k<WED.length;k++)
{

        System.out.println("Position = "+WED[k][0]);
        System.out.println("Start Month = "+WED[k][1]);
        System.out.println("Start Year = "+WED[k][2]);
        System.out.println("End Month = "+WED[k][3]);
        System.out.println("End Year = "+WED[k][4]);
        System.out.println("Description = "+WED[k][5]);

        System.out.println(" ");
}
}
}
*******************************************************

Thou I have try out myself but according to above code the length of 
array must be 2 and the following VB.NET Code returing me the length 
of array 3.

********************************* VB.NET CODE ********************

Function displayWorkExperience(ByVal WE As String) As System.String()
()

        Dim endindex As Integer = 0
        Dim plusindex As Integer = 0
        Dim count As Integer = 0
        Dim i As Integer = 0, c1 As Integer = 0, c2 As Integer = 0
        Dim value_Renamed As System.String() = New System.String(6) 
{}
        Dim WorkExperience_Data As System.String()() = Nothing
        Dim str As System.String = WE

        While CType(str <> Nothing, System.Object)
            endindex = str.IndexOf("$", 0)
            Exit While
        End While

        'Count plus

        While i < endindex
            plusindex = str.IndexOf("+", i)
            count = count + 1
            i = plusindex
            i = i + 1
        End While

        i = 0
        WorkExperience_Data = New System.String(count)() {}

        Dim i2 As Integer
        For i2 = 0 To count - 1 Step i2 + 1
            WorkExperience_Data(i2) = New System.String(6) {}
        Next

        count = 0

        While i < endindex

            plusindex = str.IndexOf("+", i)
            Dim s As System.String = str.Substring(i, (plusindex) - 
(i))

            Dim j As Integer
            For j = 0 To 6 - 1 Step j + 1
                c1 = str.IndexOf(",", c1)
                value_Renamed(j) = str.Substring(c2, (c1) - (c2))
                c1 = c1 + 1
                c2 = c1
            Next

            WorkExperience_Data(count)(0) = value_Renamed(0)
            WorkExperience_Data(count)(1) = value_Renamed(1)
            WorkExperience_Data(count)(2) = value_Renamed(2)
            WorkExperience_Data(count)(3) = value_Renamed(3)
            WorkExperience_Data(count)(4) = value_Renamed(4)
            WorkExperience_Data(count)(5) = value_Renamed(5)

            count = count + 1

            i = plusindex
            c1 = plusindex
            c2 = plusindex

            c1 = c1 + 1
            c2 = c2 + 1
            i = i + 1

        End While


        displayWorkExperience = WorkExperience_Data

    End Function

*********************************************************

Please reply to my email as soon as possible.
looking forward to your kind reply.
Regard,
Mustafa Bamboat



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/saFolB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/

<*> To unsubscribe from this group, send an email to:
     [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
     http://docs.yahoo.com/info/terms/
 

Reply via email to