473,320 Members | 1,856 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

any one who can translate this vb.net to C# ?

Public Class test1
Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
Protected WithEvents Button2 As System.Web.UI.WebControls.Button
Protected WithEvents Label1 As System.Web.UI.WebControls.Label

'NOTE: The following placeholder declaration is required by the Web Form
Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region
Private _refreshState As Boolean
Private _isRefresh As Boolean

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Me.label1.Text = "Page Refreshed =" + _isRefresh.ToString
End Sub

Protected Overrides Sub LoadViewState(ByVal savedState As Object)
Dim AllStates As Object() = savedState
MyBase.LoadViewState(AllStates(0))
_refreshState = Boolean.Parse(AllStates(1))
_isRefresh = _refreshState = Session("__ISREFRESH")
End Sub

Protected Overrides Function SaveViewState() As Object
Session("__ISREFRESH") = _refreshState
Dim AllStates() As Object = New Object(2) {}
AllStates(0) = MyBase.SaveViewState
AllStates(1) = Not (_refreshState)
Return AllStates

End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

End Sub
End Class

--
FireCrow Studio
Kylin Garden
ICQ:156134382
Nov 19 '05 #1
6 1477
That would be you, as soon as you learn C#.

You probably will get some responses. However, asking in a public newsgroup
for some stranger to rewrite your code is just plain crazy. Why? Because, as
my mother used to say, "You're going to put that into your mouth? You don't
know where it's been!" And, if you don't know C#, you will never know
whether or not what some stranger writes for you is good code or bad code.
Believe it or not, there are some terribly unscrupulous, dishonest, lazy,
and crazy people out there. The Internet doesn't have any filters on it.
Unlike certain dishonest ISPs, the Internet itself doesn't claim to protect
you from anything or anyone. And what are you going to tell your boss when
the code that you copied and pasted into his hard-bought software, that he
paid you to write, breaks? "Well, darn, boss, the total stranger that gave
it to me for free must not have known how to program correctly." If your
boss is any good, and he probably didn't become a boss by NOT being any
good, he will probably reply "I didn't pay some stranger to write my code. I
paid you. You're fired."

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Sometimes you eat the elephant.
Sometimes the elephant eats you.

"Kylin" <w0**@sohu.com> wrote in message
news:uQ**************@TK2MSFTNGP14.phx.gbl...
Public Class test1
Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
Protected WithEvents Button2 As System.Web.UI.WebControls.Button
Protected WithEvents Label1 As System.Web.UI.WebControls.Label

'NOTE: The following placeholder declaration is required by the Web
Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region
Private _refreshState As Boolean
Private _isRefresh As Boolean

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Me.label1.Text = "Page Refreshed =" + _isRefresh.ToString
End Sub

Protected Overrides Sub LoadViewState(ByVal savedState As Object)
Dim AllStates As Object() = savedState
MyBase.LoadViewState(AllStates(0))
_refreshState = Boolean.Parse(AllStates(1))
_isRefresh = _refreshState = Session("__ISREFRESH")
End Sub

Protected Overrides Function SaveViewState() As Object
Session("__ISREFRESH") = _refreshState
Dim AllStates() As Object = New Object(2) {}
AllStates(0) = MyBase.SaveViewState
AllStates(1) = Not (_refreshState)
Return AllStates

End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

End Sub
End Class

--
FireCrow Studio
Kylin Garden
ICQ:156134382

Nov 19 '05 #2
The following is produced by our Instant C# VB.NET to C# converter (it can
also be produced with our free Demo Edition at www.instantcsharp.com):

public class test1 : System.Web.UI.Page
{

#region Web Form Designer Generated Code

//This call is required by the Web Form Designer.
[System.Diagnostics.DebuggerStepThrough()]
private void InitializeComponent()
{

//INSTANT C# NOTE: Converted event handlers:
this.Load += new System.EventHandler(Page_Load);
Button1.Click += new System.EventHandler(Button1_Click);

}
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.Button Button2;
protected System.Web.UI.WebControls.Label Label1;

//NOTE: The following placeholder declaration is required by the Web
Form Designer.
//Do not delete or move it.
private object designerPlaceholderDeclaration;

//ORIGINAL LINE: Private Sub Page_Init(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles base.Init
override protected void OnInit(System.EventArgs e)
{
base.OnInit(e);
//CODEGEN: This method call is required by the Web Form
Designer
//Do not modify it using the code editor.
InitializeComponent();
}

#endregion
private bool _refreshState;
private bool _isRefresh;

//INSTANT C# NOTE: This method is an event handler
//ORIGINAL LINE: Private Sub Page_Load(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles base.Load
private void Page_Load(object sender, System.EventArgs e)
{
//Put user code to initialize the page here
this.label1.Text = "Page Refreshed =" +
_isRefresh.ToString();
}

protected override void LoadViewState(object savedState)
{
object[] AllStates = savedState;
base.LoadViewState(AllStates[0]);
_refreshState = bool.Parse(AllStates[1]);
_isRefresh = _refreshState == Session["__ISREFRESH"];
}

protected override object SaveViewState()
{
Session["__ISREFRESH"] = _refreshState;
object[] AllStates = new object[3];
AllStates[0] = base.SaveViewState();
AllStates[1] = ! (_refreshState);
return AllStates;

}

//INSTANT C# NOTE: This method is an event handler
//ORIGINAL LINE: Private Sub Button1_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button1.Click

private void Button1_Click(object sender, System.EventArgs e)
{

}
}

As Kevin mentioned, certainly learn C# yourself and verify that the
translation is correct. You certainly don't want to translate thousands of
lines of code manually, but you do need to know whether the converted code is
good or not.

Enjoy,
David Anton
www.tangiblesoftwaresolutions.com
Home of the Instant C# VB.NET to C# converter
and the Instant VB C# to VB.NET converter

"Kylin" wrote:
Public Class test1
Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
Protected WithEvents Button2 As System.Web.UI.WebControls.Button
Protected WithEvents Label1 As System.Web.UI.WebControls.Label

'NOTE: The following placeholder declaration is required by the Web Form
Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region
Private _refreshState As Boolean
Private _isRefresh As Boolean

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Me.label1.Text = "Page Refreshed =" + _isRefresh.ToString
End Sub

Protected Overrides Sub LoadViewState(ByVal savedState As Object)
Dim AllStates As Object() = savedState
MyBase.LoadViewState(AllStates(0))
_refreshState = Boolean.Parse(AllStates(1))
_isRefresh = _refreshState = Session("__ISREFRESH")
End Sub

Protected Overrides Function SaveViewState() As Object
Session("__ISREFRESH") = _refreshState
Dim AllStates() As Object = New Object(2) {}
AllStates(0) = MyBase.SaveViewState
AllStates(1) = Not (_refreshState)
Return AllStates

End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

End Sub
End Class

--
FireCrow Studio
Kylin Garden
ICQ:156134382

Nov 19 '05 #3
Yes, definitely learn C#. However, if you attempt converting thousands of
lines of code by hand your boss is going to say "are you crazy? - they have
tools for this!". For a trivial snippet it's one thing, but even for an
entire file it's error-prone and likely to induce carpal tunnel syndrome.

Learn C#, construct your own test, and then find a converter that passes
your tests.
(we obviously hope it'll be our's - Instant C#).

David Anton
www.tangiblesoftwaresolutions.com
Home of the Instant C# VB.NET to C# converter
and the Instant VB C# to VB.NET converter

"Kevin Spencer" wrote:
That would be you, as soon as you learn C#.

You probably will get some responses. However, asking in a public newsgroup
for some stranger to rewrite your code is just plain crazy. Why? Because, as
my mother used to say, "You're going to put that into your mouth? You don't
know where it's been!" And, if you don't know C#, you will never know
whether or not what some stranger writes for you is good code or bad code.
Believe it or not, there are some terribly unscrupulous, dishonest, lazy,
and crazy people out there. The Internet doesn't have any filters on it.
Unlike certain dishonest ISPs, the Internet itself doesn't claim to protect
you from anything or anyone. And what are you going to tell your boss when
the code that you copied and pasted into his hard-bought software, that he
paid you to write, breaks? "Well, darn, boss, the total stranger that gave
it to me for free must not have known how to program correctly." If your
boss is any good, and he probably didn't become a boss by NOT being any
good, he will probably reply "I didn't pay some stranger to write my code. I
paid you. You're fired."

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Sometimes you eat the elephant.
Sometimes the elephant eats you.

"Kylin" <w0**@sohu.com> wrote in message
news:uQ**************@TK2MSFTNGP14.phx.gbl...
Public Class test1
Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
Protected WithEvents Button2 As System.Web.UI.WebControls.Button
Protected WithEvents Label1 As System.Web.UI.WebControls.Label

'NOTE: The following placeholder declaration is required by the Web
Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region
Private _refreshState As Boolean
Private _isRefresh As Boolean

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Me.label1.Text = "Page Refreshed =" + _isRefresh.ToString
End Sub

Protected Overrides Sub LoadViewState(ByVal savedState As Object)
Dim AllStates As Object() = savedState
MyBase.LoadViewState(AllStates(0))
_refreshState = Boolean.Parse(AllStates(1))
_isRefresh = _refreshState = Session("__ISREFRESH")
End Sub

Protected Overrides Function SaveViewState() As Object
Session("__ISREFRESH") = _refreshState
Dim AllStates() As Object = New Object(2) {}
AllStates(0) = MyBase.SaveViewState
AllStates(1) = Not (_refreshState)
Return AllStates

End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

End Sub
End Class

--
FireCrow Studio
Kylin Garden
ICQ:156134382


Nov 19 '05 #4
Hi David,

I'm impressed!

--

Kevin Spencer
Microsoft MVP
..Net Developer
Sometimes you eat the elephant.
Sometimes the elephant eats you.

"David Anton" <Da********@discussions.microsoft.com> wrote in message
news:AB**********************************@microsof t.com...
The following is produced by our Instant C# VB.NET to C# converter (it can
also be produced with our free Demo Edition at www.instantcsharp.com):

public class test1 : System.Web.UI.Page
{

#region Web Form Designer Generated Code

//This call is required by the Web Form Designer.
[System.Diagnostics.DebuggerStepThrough()]
private void InitializeComponent()
{

//INSTANT C# NOTE: Converted event handlers:
this.Load += new System.EventHandler(Page_Load);
Button1.Click += new System.EventHandler(Button1_Click);

}
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.Button Button2;
protected System.Web.UI.WebControls.Label Label1;

//NOTE: The following placeholder declaration is required by the
Web
Form Designer.
//Do not delete or move it.
private object designerPlaceholderDeclaration;

//ORIGINAL LINE: Private Sub Page_Init(ByVal sender As System.Object,
ByVal
e As System.EventArgs) Handles base.Init
override protected void OnInit(System.EventArgs e)
{
base.OnInit(e);
//CODEGEN: This method call is required by the Web Form
Designer
//Do not modify it using the code editor.
InitializeComponent();
}

#endregion
private bool _refreshState;
private bool _isRefresh;

//INSTANT C# NOTE: This method is an event handler
//ORIGINAL LINE: Private Sub Page_Load(ByVal sender As System.Object,
ByVal
e As System.EventArgs) Handles base.Load
private void Page_Load(object sender, System.EventArgs e)
{
//Put user code to initialize the page here
this.label1.Text = "Page Refreshed =" +
_isRefresh.ToString();
}

protected override void LoadViewState(object savedState)
{
object[] AllStates = savedState;
base.LoadViewState(AllStates[0]);
_refreshState = bool.Parse(AllStates[1]);
_isRefresh = _refreshState == Session["__ISREFRESH"];
}

protected override object SaveViewState()
{
Session["__ISREFRESH"] = _refreshState;
object[] AllStates = new object[3];
AllStates[0] = base.SaveViewState();
AllStates[1] = ! (_refreshState);
return AllStates;

}

//INSTANT C# NOTE: This method is an event handler
//ORIGINAL LINE: Private Sub Button1_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button1.Click

private void Button1_Click(object sender, System.EventArgs e)
{

}
}

As Kevin mentioned, certainly learn C# yourself and verify that the
translation is correct. You certainly don't want to translate thousands
of
lines of code manually, but you do need to know whether the converted code
is
good or not.

Enjoy,
David Anton
www.tangiblesoftwaresolutions.com
Home of the Instant C# VB.NET to C# converter
and the Instant VB C# to VB.NET converter

"Kylin" wrote:
Public Class test1
Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
Protected WithEvents Button2 As System.Web.UI.WebControls.Button
Protected WithEvents Label1 As System.Web.UI.WebControls.Label

'NOTE: The following placeholder declaration is required by the Web
Form
Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region
Private _refreshState As Boolean
Private _isRefresh As Boolean

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Me.label1.Text = "Page Refreshed =" + _isRefresh.ToString
End Sub

Protected Overrides Sub LoadViewState(ByVal savedState As Object)
Dim AllStates As Object() = savedState
MyBase.LoadViewState(AllStates(0))
_refreshState = Boolean.Parse(AllStates(1))
_isRefresh = _refreshState = Session("__ISREFRESH")
End Sub

Protected Overrides Function SaveViewState() As Object
Session("__ISREFRESH") = _refreshState
Dim AllStates() As Object = New Object(2) {}
AllStates(0) = MyBase.SaveViewState
AllStates(1) = Not (_refreshState)
Return AllStates

End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

End Sub
End Class

--
FireCrow Studio
Kylin Garden
ICQ:156134382

Nov 19 '05 #5
>>You certainly don't want to translate thousands of
lines of code manually, but you do need to know whether the converted
code is
good or not. <<

Perhaps it was overkill, but I learned C# by translating thousands of
lines of VB.NET manually. It was tedious but didn't take as long as
you might think. It works!

Bill E.

Nov 19 '05 #6
Sure - do a few thousand lines to learn. But eventually there are
diminishing returns to doing it by hand.

"bi********@netscape.net" wrote:
You certainly don't want to translate thousands of

lines of code manually, but you do need to know whether the converted
code is
good or not. <<

Perhaps it was overkill, but I learned C# by translating thousands of
lines of VB.NET manually. It was tedious but didn't take as long as
you might think. It works!

Bill E.

Nov 19 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Bengt Richter | last post by:
Just thought None as the first argument would be both handy and mnemonic, signifying no translation, but allowing easy expression of deleting characters, e.g., s = s.translate(None,...
1
by: shank | last post by:
I'm sure this is a stretch, but is there some kind of component that I could install to translate from English to Spanish on the fly? I have a lot of equipment features and specifications that I...
4
by: Gadrin77 | last post by:
I have data that looks like <Root> <Main Value="Line1|Line2.|Line3|Line4.|Line5"/> </Root> I'm using Translate(@Value, "|.", ",")
6
by: bobueland | last post by:
The module string has a function called translate. I tried to find the source code for that function. In: C:\Python24\Lib there is one file called string.py I open it and it says
6
by: Anders K. Olsen | last post by:
Hello group I'm trying to list the users and groups who has read access to a file. I use .NET 2.0 and FileInfo.GetAccessControl().GetAccessRules(...) and then loop through the...
1
by: peterbe | last post by:
This has always worked fine for me. Peter fine Now if I do it with a unicode string: Traceback (most recent call last): File "<stdin>", line 1, in ? File "/usr/lib/python2.4/string.py", line...
9
bvdet
by: bvdet | last post by:
I have done some more work on a simple class I wrote to calculate a global coordinate in 3D given a local coordinate: ## Basis3D.py Version 1.02 (module macrolib.Basis3D) ## Copyright (c) 2006...
1
by: =?Utf-8?B?R2F1cmF2?= | last post by:
Hi, I am using the Translate() function in one of the .XSLT file to remove the spaces, like this: <xsl:for-each select=".//Illustration"> <xsl:value-of select="translate(./@illusName, ' ',...
3
by: Kenneth McDonald | last post by:
I have the need to occasionally translate a single word programatically. Would anyone have a Python script that would let me do this using Google (or another) translation service? Thanks, Ken
4
by: kovariadam | last post by:
Hi, Does anybody know why i get this error: SQL0176N The second, third or fourth argument of the TRANSLATE scalar function is incorrect. SQLSTATE=42815 with this query: SELECT...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.