473,383 Members | 1,896 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,383 software developers and data experts.

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

I downloaded a web timer control from
http://www.eggheadcafe.com/articles/20021006.asp and it'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
Nov 21 '05 #1
5 1459
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 --

"Unforgiven" <st*****@hotmail.com> wrote in message
news:uU**************@TK2MSFTNGP09.phx.gbl...
I downloaded a web timer control from
http://www.eggheadcafe.com/articles/20021006.asp and it'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

Nov 21 '05 #2
Hi Unforgiven,

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

http://tinyurl.com/3suad

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"
I downloaded a web timer control from
http://www.eggheadcafe.com/articles/20021006.asp and it'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

Nov 21 '05 #3
That works, thanks Shiva.

-U

Shiva wrote:
: 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 --
:
: "Unforgiven" <st*****@hotmail.com> wrote in message
: news:uU**************@TK2MSFTNGP09.phx.gbl...
: I downloaded a web timer control from
: http://www.eggheadcafe.com/articles/20021006.asp and it'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
Nov 21 '05 #4
For future reference, here's a cool tool I've used in the past.

http://www.developerfusion.com/utili...sharptovb.aspx

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

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #5
* "Unforgiven" <st*****@hotmail.com> scripsit:
I downloaded a web timer control from
http://www.eggheadcafe.com/articles/20021006.asp and it'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...


From my FAQ (<URL:http://dotnet.mvps.org/dotnet/faqs/>):

Converters for converting source code between .NET programming languages:

C# to VB.NET Translator
<URL:http://www.aspalliance.com/aldotnet/examples/translate.aspx>

ConvertCSharp2VB
<URL:http://www.kamalpatel.net/ConvertCSharp2VB.aspx>

Clarity Consulting C# Converter
<URL:http://csharpconverter.claritycon.com/>

CSharp to VB.NET Code Converter
<URL:http://www.ragingsmurf.com/vbcsharpconverter.aspx>

Convert C# to VB.NET
<URL:http://www.gotdotnet.com/Community/UserSamples/Details.aspx?SampleGuid=c622348b-18a9-47d6-8687-979975d5957d>

SharpDevelop @ic#code
<URL:http://www.icsharpcode.com/OpenSource/SD/>

Commercial:

Octopus .NET Translator
<URL:http://www.remotesoft.com/octopus/>

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

TransKing
<URL:http://www.e-iceblue.com/>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #6

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

Similar topics

6
by: Newbee Adam | last post by:
I have been reading in help how I need to use decimal becuase currency does not exist like I used in vb6. I had a difficult time on google and msdn finding how or if I can take the value of text...
2
by: Megat | last post by:
I'm trying to create a conversion program, that convert a simple proprietry programming language to an international standard languange, using Visual C++. Need some help from those who has...
8
by: prabha | last post by:
Hello Everybody, I have to conert the word doc to multiple html files,according to the templates in the word doc. I had converted the word to xml.Also through Exsl ,had finished the multiple...
5
by: Robert | last post by:
I have a series of web applications (configured as separate applications) on a server. There is a main application at the root and then several virtual directories that are independant...
27
by: sam_cit | last post by:
Hi, I needed help in converting a character to the correspoding hexadecimal values, like the following example, ASCII value : ABC Hex Code Value : %41%42%43... whats the logic of conversion...
1
by: Learner | last post by:
Hello Friends, I need help converting the below C# code snippet to vb.net. case "CreationDate": comparison = new Comparison<MembershipUserWrapper>( delegate(MembershipUserWrapper lhs,...
16
by: manmit.walia | last post by:
Hello All, I have tried multiple online tools to convert an VB6 (bas) file to VB.NET file and no luck. I was hoping that someone could help me covert this. I am new to the .NET world and still...
10
by: Hank Stalica | last post by:
I'm having this weird problem where my code does the following conversion from string to float: 27000000.0 -27000000.00 2973999.99 -29740000.00 2989999.13 -2989999.25 The number on the left...
6
by: gsBytes | last post by:
I am working with a specialized graph class, which has a node class and an edge class. In the node class, there is a list of pointers to each edge. Code that uses the graph must be able to see what...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.