Need help converting C# code to VB.NET code...

Need help converting C# code to VB.NET code...

Post by Unforgive » Sat, 11 Sep 2004 00:21:54


I downloaded a web timer control from
http://www.yqcomputer.com/ 's written in C#. The
code and .DLL comes with the download so I'm trying to convert the sample
which was written in C# to VB (ASP.NET). Here is the following code in the
Default.aspx page...

private void PgTimer1_Elapsed(object sender, System.EventArgs e)
{
if (Application["PgTimer"] == null)
{
Application["PgTimer"] = 0;
}

string strResult = "Elapsed Event: " + DateTime.Now.Millisecond;
Application["PgTimer"] = (int)Application["PgTimer"] + 1;

Response.Write("Instance: " + Application["PgTimer"].ToString() + ": " +
strResult);
}

Can anyone help me convert this to its VB.NET equivalent?

Here is what I have so far...

Private Sub PgTimer1_Elapsed(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles PgTimer1.Elapsed
Dim strResult As String
Dim intNum As Integer

strResult = "Elapsed Event: " & DateTime.Now.Millisecond

' The following line is just a placeholder only until I figure out
' how to convert the following C# code.
'
' Application["PgTimer"] = (int)Application["PgTimer"] + 1;
intNum += 1

Response.Write("Instance: " & intNum.ToString() & ": " + strResult)
End Sub
 
 
 

Need help converting C# code to VB.NET code...

Post by Shiv » Sat, 11 Sep 2004 00:41:37

Hi,
You can check this one out:

-- Not Tested --
Private Sub PgTimer1_Elapsed (ByVal sender As Object, ByVal e As EventArgs)
Handles PgTimer1.Elapsed
If (Application("PgTimer") Is Nothing) Then Application("PgTimer") = 0

Dim strResult As String = "Elapsed Event: " & DateTime.Now.Millisecond
Application("PgTimer") = DirectCast (Application("PgTimer"), Int32) + 1

Response.Write ("Instance: " & Application("PgTimer").ToString() & ": "
& strResult)
End Sub
-- Not Tested --



I downloaded a web timer control from
http://www.yqcomputer.com/ 's written in C#. The
code and .DLL comes with the download so I'm trying to convert the sample
which was written in C# to VB (ASP.NET). Here is the following code in the
Default.aspx page...

private void PgTimer1_Elapsed(object sender, System.EventArgs e)
{
if (Application["PgTimer"] == null)
{
Application["PgTimer"] = 0;
}

string strResult = "Elapsed Event: " + DateTime.Now.Millisecond;
Application["PgTimer"] = (int)Application["PgTimer"] + 1;

Response.Write("Instance: " + Application["PgTimer"].ToString() + ": " +
strResult);
}

Can anyone help me convert this to its VB.NET equivalent?

Here is what I have so far...

Private Sub PgTimer1_Elapsed(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles PgTimer1.Elapsed
Dim strResult As String
Dim intNum As Integer

strResult = "Elapsed Event: " & DateTime.Now.Millisecond

' The following line is just a placeholder only until I figure out
' how to convert the following C# code.
'
' Application["PgTimer"] = (int)Application["PgTimer"] + 1;
intNum += 1

Response.Write("Instance: " & intNum.ToString() & ": " + strResult)
End Sub

 
 
 

Need help converting C# code to VB.NET code...

Post by Cor Ligthe » Sat, 11 Sep 2004 00:46:52

Hi Unforgiven,

Some months ago OHM showed me that I gave a wrong advice and he was right.

http://www.yqcomputer.com/

I tested this as well (what is not in this thread) with the application
state, just to see the behaviour of a webpage.

From that I know that probably the Session.Item is a better choose for what
you want to do, the application goes fine when there is only one client
busy. With more pages you get probably unpredictable results/.

I show you this thread because the code you want is in my opinion almost
complete there.

Cor.



"Unforgiven"

The
 
 
 

Need help converting C# code to VB.NET code...

Post by Unforgive » Sat, 11 Sep 2004 01:13:49

That works, thanks Shiva.

-U


: Hi,
: You can check this one out:
:
: -- Not Tested --
: Private Sub PgTimer1_Elapsed (ByVal sender As Object, ByVal e As
: EventArgs) Handles PgTimer1.Elapsed
: If (Application("PgTimer") Is Nothing) Then Application("PgTimer")
: = 0
:
: Dim strResult As String = "Elapsed Event: " &
: DateTime.Now.Millisecond Application("PgTimer") = DirectCast
: (Application("PgTimer"), Int32) + 1
:
: Response.Write ("Instance: " & Application("PgTimer").ToString() &
: ": " & strResult)
: End Sub
: -- Not Tested --
:


: I downloaded a web timer control from
: http://www.yqcomputer.com/ 's written in
: C#. The code and .DLL comes with the download so I'm trying to
: convert the sample which was written in C# to VB (ASP.NET). Here is
: the following code in the Default.aspx page...
:
: private void PgTimer1_Elapsed(object sender, System.EventArgs e)
: {
: if (Application["PgTimer"] == null)
: {
: Application["PgTimer"] = 0;
: }
:
: string strResult = "Elapsed Event: " + DateTime.Now.Millisecond;
: Application["PgTimer"] = (int)Application["PgTimer"] + 1;
:
: Response.Write("Instance: " + Application["PgTimer"].ToString() + ":
: " + strResult);
: }
:
: Can anyone help me convert this to its VB.NET equivalent?
:
: Here is what I have so far...
:
: Private Sub PgTimer1_Elapsed(ByVal sender As System.Object, ByVal e As
: System.EventArgs) Handles PgTimer1.Elapsed
: Dim strResult As String
: Dim intNum As Integer
:
: strResult = "Elapsed Event: " & DateTime.Now.Millisecond
:
: ' The following line is just a placeholder only until I figure out
: ' how to convert the following C# code.
: '
: ' Application["PgTimer"] = (int)Application["PgTimer"] + 1;
: intNum += 1
:
: Response.Write("Instance: " & intNum.ToString() & ": " + strResult)
: End Sub
 
 
 

Need help converting C# code to VB.NET code...

Post by Joel Cade, » Sat, 11 Sep 2004 01:26:53

For future reference, here's a cool tool I've used in the past.

http://www.yqcomputer.com/

Joel Cade, MCSD .Net, MCAD, MCP
Fig Tree Solutions, LLC
http://www.yqcomputer.com/

*** Sent via Developersdex http://www.yqcomputer.com/ ***
Don't just participate in USENET...get rewarded for it!
 
 
 

Need help converting C# code to VB.NET code...

Post by hirf-spam- » Sat, 11 Sep 2004 01:32:11

* "Unforgiven" < XXXX@XXXXX.COM > scripsit:

From my FAQ (<URL: http://www.yqcomputer.com/ ;):

Converters for converting source code between .NET programming languages:

C# to VB.NET Translator
<URL: http://www.yqcomputer.com/ ;

ConvertCSharp2VB
<URL: http://www.yqcomputer.com/ ;

Clarity Consulting C# Converter
<URL: http://www.yqcomputer.com/ ;

CSharp to VB.NET Code Converter
<URL: http://www.yqcomputer.com/ ;

Convert C# to VB.NET
<URL: http://www.yqcomputer.com/ ;

SharpDevelop @ic#code
<URL: http://www.yqcomputer.com/ ;

Commercial:

Octopus .NET Translator
<URL: http://www.yqcomputer.com/ ;

Commercial VB/VB.NET to C# converter (rather useless):

TransKing
<URL: http://www.yqcomputer.com/ ;

--
M S Herfried K. Wagner
M V P <URL: http://www.yqcomputer.com/ ;
V B <URL: http://www.yqcomputer.com/ ;