Solved

VB.NET to C#

Posted on 2006-06-22
8
235 Views
Last Modified: 2012-05-05
Hello Experts,

I am new to C# could anyone pls tell me how to convert the following function from VB to C#

 Private Function Msgbox(ByVal strMessage As String)

        Dim strScript As String = "<script language=JavaScript>"
        strScript += "alert(""" & strMessage & """);"
        strScript += "</script>"

        If (Not Page.IsStartupScriptRegistered("clientScript")) Then
            Page.RegisterStartupScript("clientScript", strScript)
        End If

    End Function

Also:

            Dim dt As DateTime
            Dim dt1 As DateTime
            dt = New DateTime(sy, sm, sd, sh, smm, 0)
            dt1 = New DateTime(ey, em, ed, eh, emm, 0)

Any help appreciated.
0
Comment
Question by:radhakrishan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
8 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 250 total points
ID: 16960886
private void MsgBox(string strMessage)
{
    string strScript = "<script language=javascript>";
    strScript += "alert(\"" + strMessage + "\");";
    strScript += "</script>";

    if (!Page.IsStartupScriptRegistered("clientScript"))
        Page.RegisterStartupScript("clientScript", strScript);
}
0
 
LVL 18

Expert Comment

by:Ravi Singh
ID: 16960898
private void MsgBox(string strMessage)
{
     string strScript = "<script language=JavaScript>";
     strScript += "alert(\"" + strMessage + "\");";
     strScript += "</script>";

     if (!Page.IsStartupScriptRegistered("clientScript"))
     {
          Page.RegisterStartupScript("clientScript", strScript)
     }
}


DateTime dt = new DateTime(sy, sm, sd, sh, smm, 0);
DateTime dt1 = new DateTime(ey, em, ed, eh, emm, 0);
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 16960903
Second part:

    DateTime dt = new DateTime(sy, sm, sd, sh, smm, 0);
    DateTime dt1 = new DateTime(ey, em, ed, eh, emm, 0);
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 18

Expert Comment

by:Ravi Singh
ID: 16960954
sorry carl, posted on same minute!
0
 

Author Comment

by:radhakrishan
ID: 16961079
Hi Guys,

Thanks for the reply.

In the 2nd Part:

DateTime dt = new DateTime(sy, sm, sd, sh, smm, 0);
DateTime dt1 = new DateTime(ey, em, ed, eh, emm, 0);

I get an error on each argument cannot convert string to int.

Should I be writing somthing like int.Parse(sy)
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 16961100
If your variables are strings containing ints then yes.
0
 

Author Comment

by:radhakrishan
ID: 16961109
Yeah,
Thanks for the reply.
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 16961157
Thanks for the points, although I think a Split may have been more appropriate since Zephyr and myself posted the same answer at the same time.

Post a request in Community Support if you want to change the point split.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
.NET 2008 VB and C# 6 48
how to remove duplicate code from my project 5 48
Code works but breaks when I add one section 4 29
orderby list (from Json) 1 29
Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question