Please Convert this function VB.Net to C# .NET

  • Thread starter Thread starter Karunakararao
  • Start date Start date
K

Karunakararao

Hi all

Please Convert the VB.Net to C# .NET

Sub CustomPager(ByVal STCPagerGrid As Object)
Dim intCtr As Integer
Static intLastItem As Integer
Static intCount As Integer
Static intTotalPage, lintCurrentPage As Integer

For intCtr = 0 To STCPagerGrid.Controls.Count - 1

If STCPagerGrid.Controls(intCtr).GetType.ToString =
"System.Web.UI.WebControls.DataGridLinkButton" Then
If IsNumeric(STCPagerGrid.controls(intCtr).text) = True
And Left(STCPagerGrid.controls(intCtr).text, 1) <> "[" Then
STCPagerGrid.controls(intCtr).text = "[" &
STCPagerGrid.controls(intCtr).text & "]"
If STCPagerGrid.Controls(intCtr).Text = "..." And intCtr
= 0 Then
STCPagerGrid.Controls(intCtr).Text = "[<<]"
End If
If STCPagerGrid.Controls(intCtr).Text = "..." And intCtr
STCPagerGrid.Controls(intCtr).Text = "[>>]"
End If
End If
If STCPagerGrid.controls(intCtr).controls.count > 0 Then
CustomPager(STCPagerGrid.controls(intCtr))
End If
Next
End Sub


Thanks
Venu
 
How many times do you need it converted? I've seen at least three answers
today :-)

Best Regards
Julian N.

----- Original Message -----
From: "Karunakararao" <[email protected]>
Newsgroups: Microsoft.public.dotnet.languages.csharp
Sent: Monday, May 24, 2004 3:55 PM
Subject: Please Convert this function VB.Net to C# .NET

Hi all

Please Convert the VB.Net to C# .NET
<<SSSNNNIIIPPP.........>>
 
Just stumbled on your reply. Thanks for the link. I am currently trying to
make the transition from VB to VC# and this will allow me to look at
existing VB code to learn the new syntax.........This will be very helpful
to me

thx
meh
 
Pick up the free demo at Instant C# (www.instantcsharp.com). It's a
lot easier to get the answer there than to keep posting these
snippets:

//INSTANT C# NOTE: These were formerly VB static local variables:
private static int intLastItem;
private static int intCount;
private static int intTotalPage;
private static int lintCurrentPage;

public void CustomPager(object STCPagerGrid)
{
int intCtr = 0;
//INSTANT C# NOTE: VB local static variable moved to class level
//Static intLastItem As Integer
//INSTANT C# NOTE: VB local static variable moved to class level
//Static intCount As Integer
//INSTANT C# NOTE: VB local static variable moved to class level
//Static intTotalPage, lintCurrentPage As Integer
//INSTANT C# NOTE: VB local static variable moved to class level
//Static lintCurrentPage As Integer

int ForTemp1 = STCPagerGrid.Controls.Count - 1;
//INSTANT C# NOTE: The ending condition of VB 'For' loops is tested
only on entry to the loop. Instant C# has created a temporary
variable in order to use the initial value of
STCPagerGrid.Controls.Count - 1 for every iteration:
for (intCtr = 0; intCtr <= ForTemp1; intCtr++)
{

if (STCPagerGrid.Controls.GetType().ToString() ==)
{
"System.Web.UI.WebControls.DataGridLinkButton" Then;
if
(Microsoft.VisualBasic.Information.IsNumeric(STCPagerGrid.Controls[intCtr].Text)
== true)
{
//ORIGINAL LINE: And Left(STCPagerGrid.Controls[intCtr].text, 1)
<> "[" Then
& STCPagerGrid.Controls[intCtr].Text.Substring(0, 1) != "[" Then;
STCPagerGrid.Controls[intCtr].Text = "[" +;
STCPagerGrid.Controls[intCtr].Text + "]";
if (STCPagerGrid.Controls[intCtr].Text == "..." & intCtr)
{
= 0 Then;
STCPagerGrid.Controls[intCtr].Text = "[<<]";
}
if (STCPagerGrid.Controls[intCtr].Text == "..." & intCtr)
{
Microsoft.VisualBasic.ControlChars.Quote:
0 Then;
STCPagerGrid.Controls[intCtr].Text = "[>>]";

}
}
if (STCPagerGrid.Controls[intCtr].Controls.Count > 0)
{
CustomPager(STCPagerGrid.Controls[intCtr]);
}
}
}
 
Back
Top