Solved

VB.NET to C#

Posted on 2006-06-22
8
234 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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

832 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