Translation Problems (C# to VB) 
Author Message
 Translation Problems (C# to VB)

Hi,

On the internet I found the solution to a problem (that's a good thing), but
it is written in C# (that a bad thing).
I tried everything I could imagine but I can't seem to translate it to VB so
it works...
Specialy the for line makes me go crazy ;-)
Any ideas???

Thanks in advance,
Dieter

------------The code...------------
public ArrayList GetSelectedRows(DataGrid datagrid1)
{
  ArrayList al = new ArrayList();
    for(int i = 0; i < ((DataSet)dataGrid1.DataSource).Tables[0].Rows.Count;
++i)
      {
        if(datagrid1.IsSelected(i))
          al.Add(i);
      }
      return al;

Quote:
}

private void button1_Click(object sender, System.EventArgs e)
{
  string s = "Selected rows:";
  foreach(object o in GetSelectedRows(dataGrid1))
    {
      s+=""+o.ToString();
    }
    MessageBox.Show(s);
Quote:
}



Thu, 13 Jan 2005 17:47:36 GMT  
 Translation Problems (C# to VB)
Hi Dieter

Try this site:

http://www.aspalliance.com/aldotnet/examples/translate.aspx

Regards

Joe


Quote:
> Hi,

> On the internet I found the solution to a problem (that's a good thing),
but
> it is written in C# (that a bad thing).
> I tried everything I could imagine but I can't seem to translate it to VB
so
> it works...
> Specialy the for line makes me go crazy ;-)
> Any ideas???

> Thanks in advance,
> Dieter

> ------------The code...------------
> public ArrayList GetSelectedRows(DataGrid datagrid1)
> {
>   ArrayList al = new ArrayList();
>     for(int i = 0; i <

((DataSet)dataGrid1.DataSource).Tables[0].Rows.Count;

- Show quoted text -

Quote:
> ++i)
>       {
>         if(datagrid1.IsSelected(i))
>           al.Add(i);
>       }
>       return al;
> }

> private void button1_Click(object sender, System.EventArgs e)
> {
>   string s = "Selected rows:";
>   foreach(object o in GetSelectedRows(dataGrid1))
>     {
>       s+=""+o.ToString();
>     }
>     MessageBox.Show(s);
> }



Thu, 13 Jan 2005 18:41:05 GMT  
 Translation Problems (C# to VB)
Here are a couple of web links that offer C# to VB translators. They are not
perfect, but probably can handle these snippets.

http://www.aspalliance.com/aldotnet/examples/translate.aspx

http://www.kamalpatel.net/ConvertCSharp2VB.aspx

Here is a translation of the snippets you showed.

        Public Function GetSelectedRows(ByVal datagrid1 As DataGrid) As
System.Collections.ArrayList
            Dim al As New System.Collections.ArrayList()
            Dim i As Integer

            ' line assume's datasource is dataset - if datasource is
datatable 2nd option
            ' While i < CType(dataGrid1.DataSource,
DataSet).Tables(0).Rows.Count 'option 1

            While i < CType(datagrid1.DataSource, DataTable).Rows.Count
'option 2
                If datagrid1.IsSelected(i) Then
                    al.Add(i)
                End If
                i = i + 1
            End While
            Return al
        End Function 'GetSelectedRows

        Private Sub button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
            Dim s As String = "Selected rows:"
            Dim o As Object
            For Each o In GetSelectedRows(dataGrid1)
                s += " " + o.ToString()
            Next o
            MessageBox.Show(s)
        End Sub 'button1_Click
    End Class

======================
Clay Burch

Syncfusion, Inc.
Visit www.syncfusion.com for .NET Essentials


Quote:
> Hi,

> On the internet I found the solution to a problem (that's a good thing),
but
> it is written in C# (that a bad thing).
> I tried everything I could imagine but I can't seem to translate it to VB
so
> it works...
> Specialy the for line makes me go crazy ;-)
> Any ideas???

> Thanks in advance,
> Dieter

> ------------The code...------------
> public ArrayList GetSelectedRows(DataGrid datagrid1)
> {
>   ArrayList al = new ArrayList();
>     for(int i = 0; i <

((DataSet)dataGrid1.DataSource).Tables[0].Rows.Count;

- Show quoted text -

Quote:
> ++i)
>       {
>         if(datagrid1.IsSelected(i))
>           al.Add(i);
>       }
>       return al;
> }

> private void button1_Click(object sender, System.EventArgs e)
> {
>   string s = "Selected rows:";
>   foreach(object o in GetSelectedRows(dataGrid1))
>     {
>       s+=""+o.ToString();
>     }
>     MessageBox.Show(s);
> }



Thu, 13 Jan 2005 18:21:51 GMT  
 Translation Problems (C# to VB)
Thanks ! ! !


Sat, 15 Jan 2005 14:32:23 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Need some help with Some C# Bit Operator Translation

2. Convert VB.Net to C#, convert C# to VB.Net

3. VB to C# or C# to VB convertor

4. Help with problem using (EIStream) OCXs in VB.NET/C# project

5. Problem with references when mixing VB and C#

6. Problem referencing C# defined constant from VB.NET in ASPX page

7. More translation problems

8. Tell me you experience in convert code from VB 6 to VB.NET or C#

9. Translation Problems

10. C++ Translation / IP Address control problem???

11. vb3 16 bits to vb4 32 bits translation code problems

12. Problems with vb3 16 bits to vb4 32 bits translation code

 

 
Powered by phpBB® Forum Software