[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

04/09/2008 at 11:59PM PDT, ID: 23310766
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.6

Calling C# class from VB.NET

Asked by RadicalSoftwareSolutions in Microsoft Visual Basic.Net, Microsoft Visual C#.Net

Tags: VB.NET

Hi
For various reasons I need to access a C# class from within a VB project. The C# class calls an API.dll which returns fixed types which are not supported in VB.NET so the idea is to get the C# module to convert these before returning values to VB

So here's the problem - how do I get to access the C# clas in VB.NET the class is
public class API
    {
        // ¤Þ¥Î Fritz DLL
        [DllImport("DllApCli.dll")]
        public static extern void DebugMsg(int bOn);
        [DllImport("DllApCli.dll")]
        public static extern void ApOpen();
        [DllImport("DllApCli.dll")]
        unsafe public static extern int ApConnectToServer(string szSrvIP, int dwSrvPort);
        [DllImport("DllApCli.dll")]
        unsafe public static extern int ApGetVersion(out int iMajorVer, out int iMinorVer);
        [DllImport("DllApCli.dll")]
        public static extern int ApMessageCount(int hAP);
        [DllImport("DllApCli.dll")]
        public static extern void ApClose();
        [DllImport("DllApCli.dll")]
        public static extern int ApEraseAllMessage(int hAP);
        [DllImport("DllApCli.dll")]
        public static extern void ApDisconnect(int hAP);
        [DllImport("DllApCli.dll")]
        unsafe public static extern int ApGetMessage(int hAP, out long dwUnitID, out int dwMsgID, byte* szBuff, int iBuffLen);
        [DllImport("DllApCli.dll")]
        public static extern int ApAttachCount();
        [DllImport("DllApCli.dll")]
        unsafe public static extern int ApSendCmd(int hAP, long dwUnitID, byte[] szCmd, int iCmdLen);
        [DllImport("DllApCli.dll")]
        unsafe public static extern int GetNumberOfCleint();
    }

An example of the ApSendCmd method as called in a C# project is shown below

        public void SendMessage(string Message)
        {
            int IsOK;
            byte[] Msg = Encoding.Default.GetBytes(Message + "\r\n");

            IsOK = API.ApSendCmd(m_hAP, System.Convert.ToInt32(tvOBUGroup.SelectedNode.Text), Msg, Msg.Length);

            switch (IsOK)
            {
                case 0:
                    tbConsole.Text += "Send message failed." + "\r\n";
                    break;
                default:
                    tbConsole.Text += "Send " + Message + " to " + tvOBUGroup.SelectedNode.Text + "\r\n";
                    break;
            }
        }

How do I replicate this functionality in a VB.Net app?

Many thanks


[+][-]04/10/08 01:18 AM, ID: 21322673

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Microsoft Visual Basic.Net, Microsoft Visual C#.Net
Tags: VB.NET
Sign Up Now!
Solution Provided By: JasonRawlins
Participating Experts: 1
Solution Grade: B
 
 
 
Loading Advertisement...
20091111-EE-VQP-91 / EE_QW_2_20070628