Solved

VB.NET to C#

Posted on 2006-06-22
8
226 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
  • 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
 
LVL 18

Expert Comment

by:Ravi Singh
ID: 16960954
sorry carl, posted on same minute!
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now