dann11
Full Member level 3
I am trying to control a a counter with button using c# development. I have set different buttons for different counter and has an access authorization first before the counter starts counting. I have already made the authorization and it works but I have problems with buttons. I used the button name's to identify which button is clicked and which counter must operate.
I have declared ss as an object. and it keep on giving me error "Object reference not set to an instance of an object."
I believe it has something to do with the object declaration of the ss, how do you think should I declare the button if I will be using its name as a reference of an action?
Code:
public void modeOfCounter()
{
//Conditon if button1(main start button) is clicked
if (ss.Name == "button1")
{
counterA.start();
counterB.start();
counterC.start();
counterD.start();
targetSetting.Enabled = false;
button1.Enabled = false;
//disable the rest of the startbutton
aStartBtn.Enabled = false;
bStartBtn.Enabled = false;
cStartBtn.Enabled = false;
//saveButton.Enabled = false;
resetButton.Enabled = false;
}
if (ss.Name == "bc288StartBtn")
{
counterA.start();
targetSetting.Enabled = false;
aStartBtn.Enabled = false;
bStartBtn.Enabled = false;
cStartBtn.Enabled = false;
//saveButton.Enabled = false;
resetButton.Enabled = false;
button1.Enabled = false;
}
}
I have declared ss as an object. and it keep on giving me error "Object reference not set to an instance of an object."
I believe it has something to do with the object declaration of the ss, how do you think should I declare the button if I will be using its name as a reference of an action?
Last edited by a moderator: