tatton777
asked on
Need this visual basic code converted to C#
Hello,
My credit card processor provided a VB DLL for me to use in sending data to and receiving data from them. My website is in C# so I need to figure out how to incorporate this DLL into it.
In the example from the credit card processor I am to add a reference to SendPmt.dll within the VB project and then use this code
So far in my C# attempt I have added a reference to the SendPmt.dll from the processor and a reference to Microsoft.VisualBasic.dll. I think I am on the right track using the Microsoft.VisualBasic.dll but I can't seem to get it to work.
My credit card processor provided a VB DLL for me to use in sending data to and receiving data from them. My website is in C# so I need to figure out how to incorporate this DLL into it.
In the example from the credit card processor I am to add a reference to SendPmt.dll within the VB project and then use this code
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
' Initialize string
Dim strData As String
Dim strReturn As String
Dim objSendPmt As SendPmt.clsSendPmt
objSendPmt = CreateObject("SendPmt.clsSendPmt")
strData = Replace(txtInput.Text, vbCrLf, Chr(10))
strReturn = objSendPmt.SendPayment(strData, "test")
End Sub
So far in my C# attempt I have added a reference to the SendPmt.dll from the processor and a reference to Microsoft.VisualBasic.dll.
ASKER
I get a No overload for method 'CreateObject' takes '1' argument
Even though the VB example works with one parameters, CreateObject is defined as taking two.
CreateObject(string ProgId, string ServerName)
Even though the VB example works with one parameters, CreateObject is defined as taking two.
CreateObject(string ProgId, string ServerName)
pass it string.Empty as default value
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I got both of these examples to work. However, they both return the same error.
"ERR: Unable to send data to remote host 26021"
I am assuming this is coming from within the SendPmt.dll.
I just verified that the VB code worked and it does. Why would C# throw this curve ball?
"ERR: Unable to send data to remote host 26021"
I am assuming this is coming from within the SendPmt.dll.
I just verified that the VB code worked and it does. Why would C# throw this curve ball?
ASKER
Nevermind. I got this to work with the Activator code. THANKS!
protected void // ERROR: Handles clauses are not supported in C#
Button1_Click(object sender, System.EventArgs e)
{
// Initialize string
string strData = null;
string strReturn = null;
SendPmt.clsSendPmt objSendPmt = default(SendPmt.clsSendPmt);
objSendPmt = Interaction.CreateObject("SendPmt.clsSendPmt");
strData = Strings.Replace(txtInput.Text, Constants.vbCrLf, Strings.Chr(10));
strReturn = objSendPmt.SendPayment(strData, "test");
}
//=======================================================
//Service provided by Telerik (www.telerik.com)
//Conversion powered by NRefactory.
//Twitter: @telerik, @toddanglin
//Facebook: facebook.com/telerik
//=======================================================
ASKER
Thanks so much for this excellent code. The other code examples didn't fail to compile, however, yours is the only code that correctly instantiated the VB dll.
Open in new window