6 Replies - 828 Views - Last Post: 07 February 2013 - 08:25 AM Rate Topic: -----

#1 costina  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 16-November 10

No overolad for method ... takes 0 arguments error

Posted 07 February 2013 - 06:35 AM

Hi there, I'm new to C# and struggling with getting my head around Visual Studio 2010, I've written a program (reading data from a mems device using i2c) and am trying to get it to run through VS but can't even get a small test program to work.
Heres the code Ive got for the test program running from a basic form

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using EZ_B;

namespace WindowsFormsApplication2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            
        }
        
            public void Navprog(EZB ezb0, EZB ezb1, EZB ezb2, EZB ezb3, EZB ezb4)
            {
                ezb0.I2C.Start(); //full code would be inserted here once working
                MessageBox.Show("test");
            }

        private void button1_Click(object sender, EventArgs e)
        {
            Navprog(); //this line throws the error..
        }

        
}
}



The error "No overolad for method "Navprog" takes 0 arguments gets thrown up when I try to complle.

(The EZB bits are all related to the microcontroller Im using (EZ-Robot) and scope of my project is using data from a gyro, accelometer and compass module using i2c).

If anyone could shed any light on what I need to do to get it to run that would be great, sorry if its a really simple thing but I'm getting nowhere with this.

Thanks Tom

Is This A Good Question/Topic? 0
  • +

Replies To: No overolad for method ... takes 0 arguments error

#2 Ryano121  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1362
  • Posts: 3,002
  • Joined: 30-January 11

Re: No overolad for method ... takes 0 arguments error

Posted 07 February 2013 - 06:41 AM

Take a look at the method signature for the NavProg method -

public void Navprog(EZB ezb0, EZB ezb1, EZB ezb2, EZB ezb3, EZB ezb4)

As you can see it takes 5 parameters that we must supply when we call this method - 5 objects of the EZB class.

Therefore when you try and call the method using

 Navprog();


you get an error as you must supply the 5 parameters.
Was This Post Helpful? 1
  • +
  • -

#3 andrewsw  Icon User is online

  • It's just been revoked!
  • member icon

Reputation: 3624
  • View blog
  • Posts: 12,538
  • Joined: 12-December 12

Re: No overolad for method ... takes 0 arguments error

Posted 07 February 2013 - 06:46 AM

You declared your function Navprog with 5 arguments

public void Navprog(EZB ezb0, EZB ezb1, EZB ezb2, EZB ezb3, EZB ezb4)

so you have to supply five arguments to it..

If you want to have default arguments then you would need

public void Navprog(EZB ezb0 = 0, // etc..


http://msdn.microsof...y/dd264739.aspx
Was This Post Helpful? 0
  • +
  • -

#4 costina  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 16-November 10

Re: No overolad for method ... takes 0 arguments error

Posted 07 February 2013 - 07:28 AM

Thanks for the quick replys, looking at the link from msdn I tried changing it to

public void button1_Click(object sender, EventArgs e)
        {
            Navprog(ezb0, ezb1, ezb2, ezb3, ezb4); 
        }



but then get the errors "the name "ezb0" does not exist in the current context" for each of the 5.

Am I completely missing the point? Sorry for being such a dimwit!
Was This Post Helpful? 0
  • +
  • -

#5 Ryano121  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1362
  • Posts: 3,002
  • Joined: 30-January 11

Re: No overolad for method ... takes 0 arguments error

Posted 07 February 2013 - 07:34 AM

Have you learnt about parameters yet? If not maybe check out this (the bit on parameters.

You are getting the errors because you haven't created any variables inside the button click handler to pass into the method. You can't use ezb0 because they haven't been created yet. They are used in the NavProg method to use the objects that you passed in.

This post has been edited by Ryano121: 07 February 2013 - 07:35 AM

Was This Post Helpful? 1
  • +
  • -

#6 costina  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 16-November 10

Re: No overolad for method ... takes 0 arguments error

Posted 07 February 2013 - 07:42 AM

Thanks for taking the time to help me out, I think I need to do a bit more research on c# and how it works! I'll let you know if I get it working. :bigsmile:
Was This Post Helpful? 0
  • +
  • -

#7 tlhIn`toq  Icon User is online

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5583
  • View blog
  • Posts: 11,943
  • Joined: 02-June 10

Re: No overolad for method ... takes 0 arguments error

Posted 07 February 2013 - 08:25 AM

View Postcostina, on 07 February 2013 - 08:42 AM, said:

I think I need to do a bit more research on c# and how it works!



My standard beginner resources post - Updated JAN 2013


Plan your study route:
There are three routes people seem to take when learning programming.
  • Just start trying to create programs
  • Start taking apart other programs and try to figure out the language by reverse engineering
  • Follow a guided learning course (school or self-teaching books)


For the life of me I can't figure out why people try 1 & 2. I strongly suggest taking the guided learning approach. Those book authors go in a certain order for a reason: They know what they're doing and they know the best order to learn the materials.

  • First learn the language by working 2-5 "Learn C# in 30 days" type books cover to cover.
  • Do a dozen on-line tutorial projects where you build what you're told to build, the way you are told to build it WITH AN EXPLANATION OF WHY so you can learn.
  • Learn to plan before you type.
  • THEN you start designing software with a purpose.



I don't learn from reading books: I learn by doing.
Spoiler


Newbie/Rookie said:

I have little/no programming experience but I need to write a program by Friday that does XYZ.
Spoiler



Resources, references and suggestions for new programmers.
Spoiler

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1