COM COMPONENT TO PERFORM LOGOCAL OPERATIONS USING DOTNET



file->new project->Visual C#->ClassLibrary


DLL
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ClassLibrary1
{
    public class Class1
    {
        public
          int  andop(int a,int b)
        {
            return(a*b);
        }


        public
            int orop(int a, int b)
        {
            if (a == 0 && b == 0)
                return (0);
            else
                return (1);
        }


        public
            int notop(int a)
        {
            if (a == 0)
                return (1);
            else
                return (0);
        }


        public
            int nandop(int a, int b)
        {
            if (a == 1 && b == 1)
                return (0);
            else
                return(1);
        }
        public
            int norop(int a, int b)
        {
            if (a == 0 && b == 0)
                return (1);
            else
                return (0);
        }


        public
            int xorop(int a, int b)
        {
            if (a == b)
                return (0);
            else
                return (1);
        }

        public
            int xnorop(int a, int b)
        {
            if (a == b)
                return (1);
            else
                return (0);
        }

    }
}

 build a class library (press F5)

--------------------------------------------------------------------------
 file->new project->Vb->WindowsApplication

add a dll file
project->add reference->browse to select dll and clik ok

CODING
Imports ClassLibrary1

Public Class Form1
    Dim obj As Class1 = New Class1
    Dim a, b As Integer


    Private Sub ComboBox3_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox3.SelectedIndexChanged
        a = Val(ComboBox1.Text)
        b = Val(ComboBox2.Text)

        If ComboBox3.Text = "AND" Then
            TextBox1.Text = obj.andop(a, b)
            ComboBox2.Visible = True

        ElseIf ComboBox3.Text = "OR" Then
            TextBox1.Text = obj.orop(a, b)
            ComboBox2.Visible = True

        ElseIf ComboBox3.Text = "NOT" Then
            ComboBox2.Visible = False
            TextBox1.Text = obj.notop(a)

        ElseIf ComboBox3.Text = "NAND" Then
            TextBox1.Text = obj.nandop(a, b)
            ComboBox2.Visible = True

        ElseIf ComboBox3.Text = "NOR" Then
            TextBox1.Text = obj.norop(a, b)
            ComboBox2.Visible = True
      
        End If



    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        ComboBox2.Visible = True

    End Sub
End Class





OUTPUT



0 Response to "COM COMPONENT TO PERFORM LOGOCAL OPERATIONS USING DOTNET"

Post a Comment



Your IP Address is:

Browser: