Hi,
I've made a class library called: counter.
Now I want to use counter.dll in my project yahtzee.
How can I say to my form.cs that he must use that dll (soon more than 1).
And how can I call the functions that are in my counter.dll
I've already got it in references but I assume that's not enough because I can't call any function or methods from that dll.
thx

Class libraries (dll) using in a windows form
pmak
Are You Kidding me
. I scrolled and Scrolled and Scrolled but it did not ended.
Make sure 2 things:
Best Regards,
j2k
Referenced again and again but's it doesn't work, can I otherwise send my whole project with it's original classes and so on and would you talk a look how to replace that classes into class libraries
Where can I send it to
regards tom
trillian74
There are some dutch words in it because i'm from belguim
using
System;using
System.Collections.Generic;using
System.Text;namespace
Yahtzee{
class Counter{
private int aantalWorpen = 0; private int isBlocked = 0; private int blockEnter = 0; private int isStarted = 0; public void StartProgram(int progStart){
isStarted = progStart;
}
public int CheckStartProgram{
get{
return isStarted;}
}
public void Reset(int reset){
aantalWorpen = reset;
}
public void TelWorp(int worp){
aantalWorpen += worp;
}
public int AantalWorpen{
get{
return aantalWorpen;}
}
public void BlockProgram(int block){
isBlocked = block;
}
public int CheckBlockProgram{
get{
return isBlocked;}
}
public void BlockEnter(int blockE){
blockEnter = blockE;
}
public int CheckBlockEnter{
get{
return blockEnter;}
}
}
}
minhnguyen
Using Counter;
Then I get the error that he doesn't find it.
What to do
newbieneedshelp
O sry, probebly is the post length limited, didn't noticed it: rest of code begining from btnEnterFulHos until the end.
And I've got in my solution explorer under references: counter.
private
void btnEnterFulHos_Click(object sender, EventArgs e){
if (d.CheckBlockEnter == 0){
b.ZetVast(0);
b.ZetVast2(0);
b.ZetVast3(0);
b.ZetVast4(0);
b.ZetVast5(0);
btnVast1.Enabled =
false;btnVast2.Enabled =
false;btnVast3.Enabled =
false;btnVast4.Enabled =
false;btnVast5.Enabled =
false;checkBox1.Checked =
false;checkBox2.Checked =
false;checkBox3.Checked =
false;checkBox4.Checked =
false;checkBox5.Checked =
false;d.Reset(0);
d.BlockProgram(0);
txtFulHos.Text = c.WaardeFulHos.ToString(); ;
txtAantalWorpen.Text = d.AantalWorpen.ToString();
btnRollen.Enabled =
true;btnEnterFulHos.Enabled =
false;d.BlockEnter(1);
string fulHos = txtFulHos.Text; int totFulHos = int.Parse(fulHos); string totaal = txtTotaal.Text; int totaalScore = int.Parse(totaal);totaalScore += totFulHos;
txtTotaal.Text = totaalScore.ToString();
}
}
private void btnEnterGrSt_Click(object sender, EventArgs e){
if (d.CheckBlockEnter == 0){
b.ZetVast(0);
b.ZetVast2(0);
b.ZetVast3(0);
b.ZetVast4(0);
b.ZetVast5(0);
btnVast1.Enabled =
false;btnVast2.Enabled =
false;btnVast3.Enabled =
false;btnVast4.Enabled =
false;btnVast5.Enabled =
false;checkBox1.Checked =
false;checkBox2.Checked =
false;checkBox3.Checked =
false;checkBox4.Checked =
false;checkBox5.Checked =
false;d.Reset(0);
d.BlockProgram(0);
txtGrSt.Text = c.WaardeGrSt.ToString(); ;
txtAantalWorpen.Text = d.AantalWorpen.ToString();
btnRollen.Enabled =
true;btnEnterGrSt.Enabled =
false;d.BlockEnter(1);
string GrSt = txtGrSt.Text; int totGrSt = int.Parse(GrSt); string totaal = txtTotaal.Text; int totaalScore = int.Parse(totaal);totaalScore += totGrSt;
txtTotaal.Text = totaalScore.ToString();
}
}
}
}
PatrickBrynhowel
HD Land
suppose You want to use it in Form1.cs Right!
Open Form1.cs and put a line
using Yahtzee;
Then Declare Conuter;
Counter counter;
Initialize it:
counter = new Counter();
use it like this:
counter.Reset(5);
I hope it'll work.
Best Regards,
ratslav
r [dot] ahmed [at] protectstar.com
I check it!!!
Jeff Schuler
These two errors i have:
Warning 2 Could not resolve this reference. Could not locate the assembly "Counter, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. Yahtzee
Error 1 The type or namespace name 'Counter'could not be found (are you missing a using directive or an assembly reference ) C:\Mijn Documenten\yahtzee\Yahtzee\Yahtzee\Form1.cs 18 9 Yahtzee
O yeah, that dll is my original class named counter that was first in the project and i want to replace it with that dll
Ayooya
Make sure you have included the namespcace in form.cs used in Counter.dll
Create an object of Class (if non static) of which you want to call methods. and make sure Methods are Public so you can call them.
If class is satic then simply put ClassName.MethodName();
That's it try it, You are missing something that's why you are not getting method names.
Best Regards,
kidwidahair
It doesn't work, maybe it's the form that isn't correct. here you've got my code (verry long:))
using
System;using
System.Collections.Generic;using
System.ComponentModel;using
System.Data;using
System.Drawing;using
System.Text;using
System.Windows.Forms;using
Yahtzee;namespace
Yahtzee{
public partial class Form1 : Form{
Dobbelsteen a = new Dobbelsteen(); Vast b = new Vast(); Score c = new Score();Counter d =
new Counter(); int dob1; int dob2; int dob3; int dob4; int dob5; public Form1(){
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e){
btnVast1.Enabled =
false;btnVast2.Enabled =
false;btnVast3.Enabled =
false;btnVast4.Enabled =
false;btnVast5.Enabled =
false;txtEen.Text =
"0";txtTwee.Text =
"0";txtDrie.Text =
"0";txtVier.Text =
"0";txtVijf.Text =
"0";txtZes.Text =
"0";txtTOAK.Text =
"0";txtFulHos.Text =
"0";txtCarre.Text =
"0";txtKlSt.Text =
"0";txtGrSt.Text =
"0";txtChance.Text =
"0";txtYahtzee.Text =
"0";txtAantalWorpen.Text =
"0";txtSubtotaal.Text =
"0";txtTotaal.Text =
"0";}
private void btnRollen_Click(object sender, EventArgs e){
Random rnd = new Random();c.een = 0;
d.TelWorp(1);
d.StartProgram(1);
d.BlockEnter(0);
if (d.AantalWorpen == 3){
btnRollen.Enabled=
false;d.BlockProgram(1);
}
if (d.CheckBlockProgram == 1 || d.CheckStartProgram == 0){
btnVast1.Enabled =
false;btnVast2.Enabled =
false;btnVast3.Enabled =
false;btnVast4.Enabled =
false;btnVast5.Enabled =
false;}
else{
btnVast1.Enabled =
true;btnVast2.Enabled =
true;btnVast3.Enabled =
true;btnVast4.Enabled =
true;btnVast5.Enabled =
true;}
if (b.DobVast == 0){
a.Rollen(rnd.Next(1, 7));
picDob1.ImageLocation = a.Waarde +
".jpg";dob1 = a.Waarde;
}
if (b.DobVast2 == 0){
a.Rollen(rnd.Next(1, 7));
picDob2.ImageLocation = a.Waarde +
".jpg";dob2 = a.Waarde;
}
if (b.DobVast3 == 0){
a.Rollen(rnd.Next(1, 7));
picDob3.ImageLocation = a.Waarde +
".jpg";dob3 = a.Waarde;
}
if (b.DobVast4 == 0){
a.Rollen(rnd.Next(1, 7));
picDob4.ImageLocation = a.Waarde +
".jpg";dob4 = a.Waarde;
}
if (b.DobVast5 == 0){
a.Rollen(rnd.Next(1, 7));
picDob5.ImageLocation = a.Waarde +
".jpg";dob5 = a.Waarde;
}
c.ScoreEen(dob1, dob2, dob3, dob4, dob5);
c.ScoreTwee(dob1, dob2, dob3, dob4, dob5);
c.ScoreDrie(dob1, dob2, dob3, dob4, dob5);
c.ScoreVier(dob1, dob2, dob3, dob4, dob5);
c.ScoreVijf(dob1, dob2, dob3, dob4, dob5);
c.ScoreZes(dob1, dob2, dob3, dob4, dob5);
c.ScoreToak(dob1, dob2, dob3, dob4, dob5);
c.ScoreCarre(dob1, dob2, dob3, dob4, dob5);
c.ScoreFulHos(dob1, dob2, dob3, dob4, dob5);
c.ScoreGrSt(dob1, dob2, dob3, dob4, dob5);
c.ScoreChance(dob1, dob2, dob3, dob4, dob5);
c.ScoreYahtzee(dob1, dob2, dob3, dob4, dob5);
txtAantalWorpen.Text = d.AantalWorpen.ToString();
}
private void btnVast1_Click(object sender, EventArgs e){
if (b.DobVast == 0){
b.ZetVast(1);
checkBox1.Checked =
true;}
else{
b.ZetVast(0);
checkBox1.Checked =
false;}
}
private void btnVast2_Click(object sender, EventArgs e){
if (b.DobVast2 == 0){
b.ZetVast2(1);
checkBox2.Checked =
true;}
else{
b.ZetVast2(0);
checkBox2.Checked =
false;}
}
private void btnVast3_Click(object sender, EventArgs e){
if (b.DobVast3 == 0){
b.ZetVast3(1);
checkBox3.Checked =
true;}
else{
b.ZetVast3(0);
checkBox3.Checked =
false;}
}
private void btnVast4_Click(object sender, EventArgs e){
if (b.DobVast4 == 0){
b.ZetVast4(1);
checkBox4.Checked =
true;}
else{
b.ZetVast4(0);
checkBox4.Checked =
false;}
}
private void btnVast5_Click(object sender, EventArgs e){
if (b.DobVast5 == 0){
b.ZetVast5(1);
checkBox5.Checked =
true;}
else{
b.ZetVast5(0);
checkBox5.Checked =
false;}
}
private void btnEnterEen_Click(object sender, EventArgs e){
if (d.CheckBlockEnter == 0){
b.ZetVast(0);
b.ZetVast2(0);
b.ZetVast3(0);
b.ZetVast4(0);
b.ZetVast5(0);
btnVast1.Enabled =
false;btnVast2.Enabled =
false;btnVast3.Enabled =
false;btnVast4.Enabled =
false;btnVast5.Enabled =
false;checkBox1.Checked =
false;checkBox2.Checked =
false;checkBox3.Checked =
false;checkBox4.Checked =
false;checkBox5.Checked =
false;d.Reset(0);
d.BlockProgram(0);
txtEen.Text = c.WaardeEen.ToString(); ;
txtAantalWorpen.Text = d.AantalWorpen.ToString();
btnRollen.Enabled =
true;btnEnterEen.Enabled =
false;d.BlockEnter(1);
string een = txtEen.Text; int totEen = int.Parse(een); string totaal = txtTotaal.Text; int totaalScore = int.Parse(totaal);totaalScore += totEen;
txtTotaal.Text = totaalScore.ToString();
}
}
private void btnEnterTwee_Click(object sender, EventArgs e){
if (d.CheckBlockEnter == 0){
b.ZetVast(0);
b.ZetVast2(0);
b.ZetVast3(0);
b.ZetVast4(0);
b.ZetVast5(0);
btnVast1.Enabled =
false;btnVast2.Enabled =
false;btnVast3.Enabled =
false;btnVast4.Enabled =
false;btnVast5.Enabled =
false;checkBox1.Checked =
false;checkBox2.Checked =
false;checkBox3.Checked =
false;checkBox4.Checked =
false;checkBox5.Checked =
false;d.Reset(0);
d.BlockProgram(0);
txtTwee.Text = c.WaardeTwee.ToString(); ;
txtAantalWorpen.Text = d.AantalWorpen.ToString();
btnRollen.Enabled =
true;btnEnterTwee.Enabled =
false;d.BlockEnter(1);
string twee = txtTwee.Text; int totTwee = int.Parse(twee); string totaal = txtTotaal.Text; int totaalScore = int.Parse(totaal);totaalScore += totTwee;
txtTotaal.Text = totaalScore.ToString();
}
}
private void btnEnterDrie_Click(object sender, EventArgs e){
if (d.CheckBlockEnter == 0){
b.ZetVast(0);
b.ZetVast2(0);
b.ZetVast3(0);
b.ZetVast4(0);
b.ZetVast5(0);
btnVast1.Enabled =
false;btnVast2.Enabled =
false;btnVast3.Enabled =
false;btnVast4.Enabled =
false;btnVast5.Enabled =
false;checkBox1.Checked =
false;checkBox2.Checked =
false;checkBox3.Checked =
false;checkBox4.Checked =
false;checkBox5.Checked =
false;d.Reset(0);
d.BlockProgram(0);
txtDrie.Text = c.WaardeDrie.ToString(); ;
txtAantalWorpen.Text = d.AantalWorpen.ToString();
btnRollen.Enabled =
true;btnEnterDrie.Enabled =
false;d.BlockEnter(1);
string drie = txtDrie.Text; int totDrie = int.Parse(drie); string totaal = txtTotaal.Text; int totaalScore = int.Parse(totaal);totaalScore += totDrie;
txtTotaal.Text = totaalScore.ToString();
}
}
private void btnEnterVier_Click(object sender, EventArgs e){
if (d.CheckBlockEnter == 0){
b.ZetVast(0);
b.ZetVast2(0);
b.ZetVast3(0);
b.ZetVast4(0);
b.ZetVast5(0);
btnVast1.Enabled =
false;btnVast2.Enabled =
false;btnVast3.Enabled =
false;btnVast4.Enabled =
false;btnVast5.Enabled =
false;checkBox1.Checked =
false;checkBox2.Checked =
false;checkBox3.Checked =
false;checkBox4.Checked =
false;checkBox5.Checked =
false;d.Reset(0);
d.BlockProgram(0);
txtVier.Text = c.WaardeVier.ToString(); ;
txtAantalWorpen.Text = d.AantalWorpen.ToString();
btnRollen.Enabled =
true;btnEnterVier.Enabled =
false;d.BlockEnter(1);
string vier = txtVier.Text; int totVier = int.Parse(vier); string totaal = txtTotaal.Text; int totaalScore = int.Parse(totaal);totaalScore += totVier;
txtTotaal.Text = totaalScore.ToString();
}
}
private void btnEnterVijf_Click(object sender, EventArgs e){
if (d.CheckBlockEnter == 0){
b.ZetVast(0);
b.ZetVast2(0);
b.ZetVast3(0);
b.ZetVast4(0);
b.ZetVast5(0);
btnVast1.Enabled =
false;btnVast2.Enabled =
false;btnVast3.Enabled =
false;btnVast4.Enabled =
false;btnVast5.Enabled =
false;checkBox1.Checked =
false;checkBox2.Checked =
false;checkBox3.Checked =
false;checkBox4.Checked =
false;checkBox5.Checked =
false;d.Reset(0);
d.BlockProgram(0);
txtVijf.Text = c.WaardeVijf.ToString(); ;
txtAantalWorpen.Text = d.AantalWorpen.ToString();
btnRollen.Enabled =
true;btnEnterVijf.Enabled =
false;d.BlockEnter(1);
string vijf = txtVijf.Text; int totVijf = int.Parse(vijf); string totaal = txtTotaal.Text; int totaalScore = int.Parse(totaal);totaalScore += totVijf;
txtTotaal.Text = totaalScore.ToString();
}
}
private void btnEnterZes_Click(object sender, EventArgs e){
if (d.CheckBlockEnter == 0){
b.ZetVast(0);
b.ZetVast2(0);
b.ZetVast3(0);
b.ZetVast4(0);
b.ZetVast5(0);
btnVast1.Enabled =
false;btnVast2.Enabled =
false;btnVast3.Enabled =
false;btnVast4.Enabled =
false;btnVast5.Enabled =
false;checkBox1.Checked =
false;checkBox2.Checked =
false;checkBox3.Checked =
false;checkBox4.Checked =
false;checkBox5.Checked =
false;d.Reset(0);
d.BlockProgram(0);
txtZes.Text = c.WaardeZes.ToString(); ;
txtAantalWorpen.Text = d.AantalWorpen.ToString();
btnRollen.Enabled =
true;btnEnterZes.Enabled =
false;d.BlockEnter(1);
string zes = txtZes.Text; int totZes = int.Parse(zes); string totaal = txtTotaal.Text; int totaalScore = int.Parse(totaal);totaalScore += totZes;
txtTotaal.Text = totaalScore.ToString();
}
}
private void btnYahtzee_Click(object sender, EventArgs e){
if (d.CheckBlockEnter == 0){
b.ZetVast(0);
b.ZetVast2(0);
b.ZetVast3(0);
b.ZetVast4(0);
b.ZetVast5(0);
btnVast1.Enabled =
false;btnVast2.Enabled =
false;btnVast3.Enabled =
false;btnVast4.Enabled =
false;btnVast5.Enabled =
false;checkBox1.Checked =
false;checkBox2.Checked =
false;checkBox3.Checked =
false;checkBox4.Checked =
false;checkBox5.Checked =
false;d.Reset(0);
d.BlockProgram(0);
txtYahtzee.Text = c.WaardeYahtzee.ToString(); ;
txtAantalWorpen.Text = d.AantalWorpen.ToString();
btnRollen.Enabled =
true;btnEnterYahtzee.Enabled =
false;d.BlockEnter(1);
string yahtzee = txtYahtzee.Text; int totYahtzee = int.Parse(yahtzee); string totaal = txtTotaal.Text; int totaalScore = int.Parse(totaal);totaalScore += totYahtzee;
txtTotaal.Text = totaalScore.ToString();
}
}
private void btnEnterToak_Click(object sender, EventArgs e){
if (d.CheckBlockEnter == 0){
b.ZetVast(0);
b.ZetVast2(0);
b.ZetVast3(0);
b.ZetVast4(0);
b.ZetVast5(0);
btnVast1.Enabled =
false;btnVast2.Enabled =
false;btnVast3.Enabled =
false;btnVast4.Enabled =
false;btnVast5.Enabled =
false;checkBox1.Checked =
false;checkBox2.Checked =
false;checkBox3.Checked =
false;checkBox4.Checked =
false;checkBox5.Checked =
false;d.Reset(0);
d.BlockProgram(0);
txtTOAK.Text = c.WaardeToak.ToString(); ;
txtAantalWorpen.Text = d.AantalWorpen.ToString();
btnRollen.Enabled =
true;btnEnterToak.Enabled =
false;d.BlockEnter(1);
string toak = txtTOAK.Text; int totToak = int.Parse(toak); string totaal = txtTotaal.Text; int totaalScore = int.Parse(totaal);totaalScore += totToak;
txtTotaal.Text = totaalScore.ToString();
}
}
private void btnEnterCarre_Click(object sender, EventArgs e){
if (d.CheckBlockEnter == 0){
b.ZetVast(0);
b.ZetVast2(0);
b.ZetVast3(0);
b.ZetVast4(0);
b.ZetVast5(0);
btnVast1.Enabled =
false;btnVast2.Enabled =
false;btnVast3.Enabled =
false;btnVast4.Enabled =
false;btnVast5.Enabled =
false;checkBox1.Checked =
false;checkBox2.Checked =
false;checkBox3.Checked =
false;checkBox4.Checked =
false;checkBox5.Checked =
false;d.Reset(0);
d.BlockProgram(0);
txtCarre.Text = c.WaardeCarre.ToString(); ;
txtAantalWorpen.Text = d.AantalWorpen.ToString();
btnRollen.Enabled =
true;btnEnterCarre.Enabled =
false;d.BlockEnter(1);
string carre = txtCarre.Text; int totCarre = int.Parse(carre); string totaal = txtTotaal.Text; int totaalScore = int.Parse(totaal);totaalScore += totCarre;
txtTotaal.Text = totaalScore.ToString();
}
}
private void btnEnterChance_Click(object sender, EventArgs e){
if (d.CheckBlockEnter == 0){
b.ZetVast(0);
b.ZetVast2(0);
b.ZetVast3(0);
b.ZetVast4(0);
b.ZetVast5(0);
btnVast1.Enabled =
false;btnVast2.Enabled =
false;btnVast3.Enabled =
false;btnVast4.Enabled =
false;btnVast5.Enabled =
false;checkBox1.Checked =
false;checkBox2.Checked =
false;checkBox3.Checked =
false;checkBox4.Checked =
false;checkBox5.Checked =
false;d.Reset(0);
d.BlockProgram(0);
txtChance.Text = c.WaardeChance.ToString(); ;
txtAantalWorpen.Text = d.AantalWorpen.ToString();
btnRollen.Enabled =
true;btnEnterChance.Enabled =
false;d.BlockEnter(1);
string chance = txtChance.Text; int totChance = int.Parse(chance); string totaal = txtTotaal.Text; int totaalScore = int.Parse(totaal);totaalScore += totChance;
txtTotaal.Text = totaalScore.ToString();
}
}
private void btnEnterFulHos_Click(object sender, EventArgs e){
if (d.CheckBlockEnter == 0){
b.ZetVast(0);
b.ZetVast2(0);
b.ZetVast3(0);
b.ZetVast4(0);
b.ZetVast5(0);
btnVast1.Enabled =
false;btnVast2.Enabled =
false;btnVast3.Enabled =
false;btnVast4.Enabled =
false;btnVast5.Enabled =
false;checkBox1.Checked =
false;checkBox2.Checked =
false;checkBox3.Checked =
false;checkBox4.Checked =
false;checkBox5.Checked =
false;d.Reset(0);
d.BlockProgram(0);
txtFulHos.Text = c.WaardeFulHos.ToString(); ;
txtAantalWorpen.Text = d.AantalWorpen.ToString();
btnRollen.Enabled =
true;btnEnterFulHos.Enabled =
false;d.BlockEnter(1);
string fulHos = txtFulHos.Text; int totFulHos = int.Parse(fulHos); string totaal = txtTotaal.Text; int totaalScore = int.Parse(totaal);totaalScore += totFulHos;
txtTotaal.Text = totaalScore.ToString();
}
}
private void btnEnterGrSt_Click(object sender, EventArgs e){
if (d.CheckBlockEnter == 0){
b.ZetVast(0);
b.ZetVast2(0);
b.ZetVast3(0);
b.ZetVast4(0);
b.ZetVast5(0);
btnVast1.Enabled =
false;btnVast2.Enabled =
false;btnVast3.Enabled =
false;btnVast4.Enabled =
false;btnVast5.Enabled =
false;checkBox1.Checked =
false;checkBox2.Checked =
false;checkBox3.Checked =
false;checkBox4.Checked =
false;checkBox5.Checked =
false;d.Reset(0);
d.BlockProgram(0);
txtGrSt.Text = c.WaardeGrSt.ToString(); ;
txtAantalWorpen.Text = d.AantalWorpen.ToString();
btnRollen.Enabled =
true;btnEnterGrSt.Enabled =
false;d.BlockEnter(1);
string GrSt = txtGrSt.Text; int totGrSt = int.Parse(GrSt); string totaal = txtTotaal.Text; int totaalScore = int.Parse(totaal);totaalScore += totGrSt;
txtTotaal.Text = totaalScore.ToString();
}
}
}
}
susanasusana
It means your DLL is not correctly referenced delete the reference and add refercne again then try to compile your code again.
Best Regards,