Question How to convert those to VB?

raysefo

Well-known member
Joined
Jul 21, 2010
Messages
207
Programming Experience
Beginner
Hi,

I have to convert c# to VB but could not manage to do it.

Any help would be great.

Thanks in advance.

Best Regards.

DataSet ds = new DataSet();
int b = (from objds in ds.Tables.Cast<DataTable>()
select FindRows(((DataTable)objds))
).Count();

private bool FindRows(DataTable dataTable)
{
DataRow b = (from objtbl in dataTable.Rows.Cast<DataRow>()
where Convert.ToBoolean(objtbl["isChecked"]) == false
select objtbl).FirstOrDefault();
if (b != null)
{
string str = b["ID"].ToString();
//set your values here
return true;
}
else
return false;

}
 
Convert C# to VB.NET - A free code conversion tool - developer Fusion
VB.NET:
Private ds As New DataSet()
Private b As Integer = (From objds In ds.Tables.Cast(Of DataTable)()FindRows(DirectCast(objds, DataTable))).Count()

Private Function FindRows(dataTable As DataTable) As Boolean
	Dim b As DataRow = (From objtbl In dataTable.Rows.Cast(Of DataRow)() Where Convert.ToBoolean(objtbl("isChecked")) = Falseobjtbl).FirstOrDefault()
	If b IsNot Nothing Then
		Dim str As String = b("ID").ToString()
		'set your values here
		Return True
	Else
		Return False
	End If

End Function
I'd guess that you can add any finishing touches required.
 
Hi,

I m getting errors. I already used the page you sent to me.

First error:
Private b As Integer = (From objds In ds.Tables.Cast(Of DataTable)()FindRows(DirectCast(objds, DataTable))).Count() ---> ')' expected

Second Error:
Dim b As DataRow = (From objtbl In dataTable.Rows.Cast(Of DataRow)() Where Convert.ToBoolean(objtbl("isChecked")) = Falseobjtbl).FirstOrDefault() ----> Cast is not a member of System.Data.DataRowCollection
 
You're allowed to read the code. If you were to write it yourself, what would you do? Wouldn't you put a dot before calling the FindRows method, just as you do for absolutely every method. As for the second error, I'm not sure why you're getting that one as Cast is a valid method. Regardless, you should probably use DataTable.AsEnumerable rather than DataTable.Rows.Cast.
 
Back
Top