473,785 Members | 2,489 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_Elapse d(object sender, System.EventArg s e)
{
if (Application["PgTimer"] == null)
{
Application["PgTimer"] = 0;
}

string strResult = "Elapsed Event: " + DateTime.Now.Mi llisecond;
Application["PgTimer"] = (int)Applicatio n["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_Elapse d(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles PgTimer1.Elapse d
Dim strResult As String
Dim intNum As Integer

strResult = "Elapsed Event: " & DateTime.Now.Mi llisecond

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

Response.Write( "Instance: " & intNum.ToString () & ": " + strResult)
End Sub
Nov 21 '05 #1
5 1483
Hi,
You can check this one out:

-- Not Tested --
Private Sub PgTimer1_Elapse d (ByVal sender As Object, ByVal e As EventArgs)
Handles PgTimer1.Elapse d
If (Application("P gTimer") Is Nothing) Then Application("Pg Timer") = 0

Dim strResult As String = "Elapsed Event: " & DateTime.Now.Mi llisecond
Application("Pg Timer") = DirectCast (Application("P gTimer"), Int32) + 1

Response.Write ("Instance: " & Application("Pg Timer").ToStrin g() & ": "
& strResult)
End Sub
-- Not Tested --

"Unforgiven " <st*****@hotmai l.com> wrote in message
news:uU******** ******@TK2MSFTN GP09.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_Elapse d(object sender, System.EventArg s e)
{
if (Application["PgTimer"] == null)
{
Application["PgTimer"] = 0;
}

string strResult = "Elapsed Event: " + DateTime.Now.Mi llisecond;
Application["PgTimer"] = (int)Applicatio n["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_Elapse d(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles PgTimer1.Elapse d
Dim strResult As String
Dim intNum As Integer

strResult = "Elapsed Event: " & DateTime.Now.Mi llisecond

' The following line is just a placeholder only until I figure out
' how to convert the following C# code.
'
' Application["PgTimer"] = (int)Applicatio n["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_Elapse d(object sender, System.EventArg s e)
{
if (Application["PgTimer"] == null)
{
Application["PgTimer"] = 0;
}

string strResult = "Elapsed Event: " + DateTime.Now.Mi llisecond;
Application["PgTimer"] = (int)Applicatio n["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_Elapse d(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles PgTimer1.Elapse d
Dim strResult As String
Dim intNum As Integer

strResult = "Elapsed Event: " & DateTime.Now.Mi llisecond

' The following line is just a placeholder only until I figure out
' how to convert the following C# code.
'
' Application["PgTimer"] = (int)Applicatio n["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_Elapse d (ByVal sender As Object, ByVal e As
: EventArgs) Handles PgTimer1.Elapse d
: If (Application("P gTimer") Is Nothing) Then Application("Pg Timer")
: = 0
:
: Dim strResult As String = "Elapsed Event: " &
: DateTime.Now.Mi llisecond Application("Pg Timer") = DirectCast
: (Application("P gTimer"), Int32) + 1
:
: Response.Write ("Instance: " & Application("Pg Timer").ToStrin g() &
: ": " & strResult)
: End Sub
: -- Not Tested --
:
: "Unforgiven " <st*****@hotmai l.com> wrote in message
: news:uU******** ******@TK2MSFTN GP09.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_Elapse d(object sender, System.EventArg s e)
: {
: if (Application["PgTimer"] == null)
: {
: Application["PgTimer"] = 0;
: }
:
: string strResult = "Elapsed Event: " + DateTime.Now.Mi llisecond;
: Application["PgTimer"] = (int)Applicatio n["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_Elapse d(ByVal sender As System.Object, ByVal e As
: System.EventArg s) Handles PgTimer1.Elapse d
: Dim strResult As String
: Dim intNum As Integer
:
: strResult = "Elapsed Event: " & DateTime.Now.Mi llisecond
:
: ' The following line is just a placeholder only until I figure out
: ' how to convert the following C# code.
: '
: ' Application["PgTimer"] = (int)Applicatio n["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*****@hotmai l.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>

ConvertCSharp2V B
<URL:http://www.kamalpatel. net/ConvertCSharp2V B.aspx>

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

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

Convert C# to VB.NET
<URL:http://www.gotdotnet.c om/Community/UserSamples/Details.aspx?Sa mpleGuid=c62234 8b-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
3198
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 box as decimal or do I just have to make another decimal variable .. So I took a guess hoping CDec would come up blue if I type it in with no squigglies on the line. But is this actually converting it to decimal. Next if so, I do not like the...
2
1444
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 experience or anyone who has any idea in creating such program. Really appreciate your help. Thank you
8
5745
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 output html files. The problem is while reading through the worddoc paragraph,the special characters are not identified. So in the xml file,it's just storing that as "?".So I couldn't able to retrive the characters in my ouput html files.
5
2527
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 applications. I am testing an upgrade of all of the sites and have converted the main root site...although not necessarily fixed any issues. I move on instead and converted one of the virtual roots that is a seperate
27
1985
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
977
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, MembershipUserWrapper rhs) { return lhs.CreationDate.CompareTo(rhs.CreationDate);
16
5450
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 learning all help would be greatly apperciated. Attribute VB_Name = "Module1" Option Explicit
10
3246
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 is the string I get after tokenizing a bigger string. The number on the right is the number I get after the conversion.
6
1970
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 edges are contained in a node. This is handled by returning a const reference to a list of edge pointers, i.e: const list<Edge*>& Node::getEdges() const { return edges; // list<Edge*> } However, I don't like this because code outside the...
0
9485
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10356
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10161
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10098
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8986
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7506
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5390
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3662
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2890
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.