none
Value cannot be null. Parameter name: value

    Question

  • I am getting this error with this code:

    Value cannot be null. Parameter name: value

     

     

     

    For index As Integer = 1 To DataGridView2.Rows.Count
    
          Dim searchVar As String = DataGridView2.Rows(index).Cells(0).Value
    
          If Not (searchVar Is System.DBNull.Value) Then
    
            If (DataGridView1.Rows(1).Cells(2).Value.ToString().Contains(searchVar)) Then
    
              MsgBox(DataGridView2.Rows(index).Cells(0).Value)
    
            End If
    
          End If
    
        Next

     

    • Moved by Hengzhe Li Wednesday, April 20, 2011 7:15 AM Forum Cleanup (From:MSDN, TechNet, and Expression Profile and Recognition System Discussions)
    Tuesday, November 09, 2010 4:11 PM

All replies

  • What exactly does this error mean:

    Is my idea to have a dll generate an event for Matlab simply not possible?
    - Is there a mistake in my code?

    - Am I choosing the wrong approach, is tehre a better way?

    ----------------------------------------------------------------------------------------------------

    The ComInterface.dll code:

    using System;
    
    using System.IO.Ports;
    
    
    
    namespace ComInterface
    
    {jutsu
    
     // Prototype for MatLab callback function
    
     public delegate void AnswerEvent(object sender, string msg);
    
    
    
     public class RS232
    
     {
    
    
     static SerialPort port;
    
     public static AnswerEvent matlabCallback;
    
    
    
     // Function to setup and open the serial port
    
     public static SerialPort Open(string portName)
    
     {pancake recipes
    
     // Specify port settings
    
     port = new SerialPort(portName);
    
     port.BaudRate = 115200;
    
     port.Parity = Parity.Odd;
    
     port.StopBits = StopBits.One;
    
     port.Handshake = Handshake.None;
    
     port.ReadTimeout = 10;
    
     port.WriteTimeout = 10;
    
    
    
     // Open serial port
    
     if (! port.IsOpen)
    
     {
    
     port.Open();
    
     }
    
     
    
     // Clear runt buffer data
    
     port.DiscardInBuffer();
    
     port.DiscardOutBuffer();
    
    
    
     // Register serial port callback function
    
     port.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived);
    
    
    
     // Just for debugging
    
     return port; 
    
     }
    
    
    
    
    
    
    
     // Function to read data from external device
    
     public static int ReadRegister(int addr, AnswerEvent fnc)
    
     {
    
     
    
     // Store Matlab callback function (could this be done differently?)
    
     matlabCallback = fnc;
    
    
    
     // Device stecific message protocol:
    
     // 1. Byte = Status (0x00 = Read)
    
     // 2. Byte = Address
    
     // 3.-6. Byte = 4 Byte Data
    
     byte[] sendMsg = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
    
     sendMsg[1] = Convert.ToByte(addr);
    
    
    
     // Send read request to device
    
     port.Write(sendMsg, 0, 6);
    
    
    
     // Just for debugging
    
     return 1;
    
     }
    
    
    
    
    
    
    
     // Callback function from serial port
    
     public static void port_DataReceived(object sender, SerialDataReceivedEventArgs e)
    
     {
    
     byte[] rcvMsg = new byte[6];
    
    
    
     // Read answer from external deice
    
     port.Read(rcvMsg, 0, 6);
    
    
    
     // Call event handler function in Matlab
    
     // => This leads to System error (Matlab crashes): ".NET unhandled exception: Asynchronous delegate invocation is not supported."
    
     matlabCallback(port, BitConverter.ToString(rcvMsg)); 
    
    
    
     // What happens here? Does program go to matlab and never come back? Is there another way to generate an event?
    
     // Better Question: Is MatLab still waiting to be called back???
    
     }
    
     }
    
    }
    Thursday, August 25, 2011 8:20 PM