当前位置:编程学习 > C#/ASP.NET >>

初学C#求大侠们帮帮忙啊



这是源文件VB。net的模块
Option Strict Off
Option Explicit On
Module PowerMILLvb


Dim pml_server As Object
    Private Sub pml_debug_mess(ByRef str_Renamed As String)
        MsgBox(str_Renamed, MsgBoxStyle.Critical, "Debug Message")
    End Sub
Public Function pm_start(ByRef start_new As Boolean) As Boolean
        On Error Resume Next
Err.Clear()

pm_start = False
If Not start_new Then
pml_server = GetObject( , "Pmill.Document")
If Err.Number Then
'pml_debug_mess "无法连上启动的PowerMILL"
'              & Chr(13) & "尝试启动..."
Err.Clear()
Else
pm_start = True
End If
End If

If Not pm_start Then
pml_server = CreateObject("Pmill.Document")
If Err.Number Then
pml_debug_mess("无法启动PowerMILL")
Err.Clear()
Else
pm_start = True
If Not start_new Then
pml_server.Visible = True

End If
End If
End If

End Function

Public Function pm_disconnect() As Boolean
pml_server = Nothing
pm_disconnect = True
    End Function
Public Function pm_send(ByRef str_Renamed As String) As Boolean
        pm_send = False
On Error Resume Next
Err.Clear()
Dim error_Renamed As Integer
pml_server.Execute(str_Renamed, error_Renamed)
If error_Renamed = 0 And Err.Number = 0 Then
pm_send = True
Else
pml_debug_mess("发送指令失败")
End If
Err.Clear()
    End Function
Public Function pm_send_ex(ByRef str_Renamed As String) As String
pm_send_ex = CStr(False)
On Error Resume Next
Err.Clear()
        Dim pml_error As Integer
Dim result As String
result = "NONE"
pml_server.ExecuteEx(str_Renamed, pml_error, result)
If pml_error = 0 And Err.Number = 0 Then

result = Replace(result, "/", "\")
result = Replace(result, Chr(9), "") '\t
result = Replace(result, Chr(13), "") '\n
result = Replace(result, Chr(&HD), "")
result = Replace(result, Chr(&HA), "")
result = Mid(result, InStr(result, "]") + 1)
pm_send_ex = result
Else
pml_debug_mess("发送指令失败,无返回信息")
End If
Err.Clear()

End Function
End Module
用在网上下的转换软件转换成成C#的代码后就出现错误了
吧vb.net的模块做成类之后用C#引用还是有问题
小弟实在是没办法了求哥哥姐姐们出手相助啊


using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Diagnostics;
using Microsoft.VisualBasic;
using System.Linq;
using System;
using System.Collections;
using System.Xml.Linq;
using System.Windows.Forms;


namespace WindowsApplication1
{
sealed class PowerMILLvb
{


static object pml_server;
private static void pml_debug_mess(string str_Renamed)
{
Interaction.MsgBox(str_Renamed, MsgBoxStyle.Critical, "Debug Message");
}
public static bool pm_start(bool start_new)
{
bool returnValue;
Information.Err().Clear();

returnValue = false;
if (! start_new)
{
pml_server = Interaction.GetObject(null, "Pmill.Document");
if (Information.Err().Number)
{
//pml_debug_mess "无法连上启动的PowerMILL"
//              & Chr(13) & "尝试启动..."
Information.Err().Clear();
}
else
{
returnValue = true;
}
}

if (! returnValue)
{
pml_server = Interaction.CreateObject("Pmill.Document", "");
if (Information.Err().Number)
{
pml_debug_mess("无法启动PowerMILL");
Information.Err().Clear();
}
else
{
returnValue = true;
if (! start_new)
{
pml_server.Visible = true;

}
}
}

return returnValue;
}

public static bool pm_disconnect()
{
bool returnValue;
pml_server = null;
returnValue = true;
return returnValue;
}
public static bool pm_send(string str_Renamed)
{
bool returnValue;
returnValue = false;
//On Error Resume Next VBConversions Warning: On Error Resume Next not supported in C#
Information.Err().Clear();
int error_Renamed;
pml_server.Execute(str_Renamed, error_Renamed);
if (error_Renamed == 0 && Information.Err().Number == 0)
{
returnValue = true;
}
else
{
pml_debug_mess("发送指令失败");
}
Information.Err().Clear();
return returnValue;
}
public static string pm_send_ex(string str_Renamed)
{
string returnValue;
returnValue = false.ToString();
//On Error Resume Next VBConversions Warning: On Error Resume Next not supported in C#
Information.Err().Clear();
int pml_error;
string result;
result = "NONE";
pml_server.ExecuteEx(str_Renamed, pml_error, result);
if (pml_error == 0 && Information.Err().Number == 0)
{
result = result.Replace("/", "\\");
result = result.Replace("\t", ""); //\t
result = result.Replace("\r", ""); //\n
result = result.Replace("\r", "");
result = result.Replace("\n", "");
result = result.Substring(result.IndexOf("]") + 2 - 1);
returnValue = result;
}
else
{
pml_debug_mess("发送指令失败,无返回信息");
}
Information.Err().Clear();
return returnValue;
}
}
}
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,