You must Sign In to post a response.
  • Category: ASP.NET

    Can somebody please convert this C# code to VB.Net

    Hai,
    Can anybody please convert this C# code to VB.net

    string userName = "xxxxx";
    string password = "xxxxx";
    string uRL;
    StreamReader objReader;
    uRL = "http://sms.openmarket.com/sms/v1/send?user=" + userName + "&pass=" + password + "&smsto=91" + txtMobileNumber.Text + "&smsmsg=" + txtMessage.Text;
    WebRequest webRequest;
    webRequest = WebRequest.Create(uRL);
    try
    {
    Stream objStream;
    objStream = webRequest.GetResponse().GetResponseStream();
    objReader = new StreamReader(objStream);
    objReader.Close();
    }
    catch (Exception ex)
    {
    ex.ToString();
    }

    Thanks in advance.
  • #696159
    try this

    use Imports System.IO



    Private Sub DoWork()

    Dim userName As String = "xxxxx"
    Dim password As String = "xxxxx"
    Dim uRL As String

    Dim objReader As StreamReader
    uRL = "http://sms.openmarket.com/sms/v1/send?user=" + userName + "&pass=" + password + "&smsto=91" + txtMobileNumber.Text + "&smsmsg=" + txtMessage.Text

    Dim webRequest As Net.WebRequest
    webRequest = Net.WebRequest.Create(uRL)

    Try
    Dim objStream As Stream
    objStream = webRequest.GetResponse().GetResponseStream()
    objReader = New StreamReader(objStream)
    objReader.Close()
    Catch ex As Exception
    ex.ToString()
    End Try


    End Sub


    Regards,
    Shine

  • #696160
    Hi,

    Converted vb.net code as follows:

    Dim userName As String = "xxxxx"
    Dim password As String = "xxxxx"
    Dim uRL As String
    Dim objReader As StreamReader
    uRL = (("http://sms.openmarket.com/sms/v1/send?user=" & userName & "&pass=" & password & "&smsto=91") + txtMobileNumber.Text & "&smsmsg=") + txtMessage.Text
    Dim webRequest__1 As WebRequest
    webRequest__1 = WebRequest.Create(uRL)
    Try
    Dim objStream As Stream
    objStream = webRequest__1.GetResponse().GetResponseStream()
    objReader = New StreamReader(objStream)
    objReader.Close()
    Catch ex As Exception
    ex.ToString()
    End Try


    Hope it will be useful.

    Regards,
    T.N. THEAAVARAAJ
    Senior Software Engineer,
    Microsoft Certified Technology Specialist.
    Email:devabe2005@gmail.com

  • #696165
    Hi,

    try like this way


    Dim userName As String = "xxxxx"
    Dim password As String = "xxxxx"
    Dim uRL As String
    Dim objReader As StreamReader
    uRL = "http://sms.openmarket.com/sms/v1/send?user=" + userName + "&pass=" + password + "&smsto=91" + txtMobileNumber.Text + "&smsmsg=" + txtMessage.Text
    Dim webRequest As WebRequest
    webRequest = WebRequest.Create(uRL)
    Try
    Dim objStream As Stream
    objStream = webRequest.GetResponse().GetResponseStream()
    objReader = New StreamReader(objStream)
    objReader.Close()
    Catch ex As Exception
    ex.ToString()
    End Try

    Regards
    N.Ravindran
    Your Hard work never fails

  • #696171
    Hi,

    You can use the code converter tool from our menu.

    Dim userName As String = "xxxxx"
    Dim password As String = "xxxxx"
    Dim uRL As String
    Dim objReader As StreamReader
    uRL = (("http://sms.openmarket.com/sms/v1/send?user=" & userName & "&pass=" & password & "&smsto=91") + txtMobileNumber.Text & "&smsmsg=") + txtMessage.Text
    Dim webRequest__1 As WebRequest
    webRequest__1 = WebRequest.Create(uRL)
    Try
    Dim objStream As Stream
    objStream = webRequest__1.GetResponse().GetResponseStream()
    objReader = New StreamReader(objStream)
    objReader.Close()
    Catch ex As Exception
    ex.ToString()
    End Try


    Regards,
    Asheej T K

  • #696195
    Hi Pawan,

    Go to http://www.developerfusion.com/tools/convert/csharp-to-vb/ Link


    You can easily convert vb.net code to c#.net code and vicevarsa online.


    Thanks & Regards

    Manoj Kumar

  • #696309
    Thanks for all the responses.I will go ahead with the converted code.
    Regards,
    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)
    pawansoftit@gmail.com


  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.