Does anyone know what’s wrong with the code below? The this->progressBar1->Value part worked by the button_click_event but not in this snippet. I’ve been messing around with it but to no avail:
int Trouble ()
{
int hour = System::DateTime::Now.Hour;
this->progressBar1->Value = hour;
return 0;
}
This code snippet is part of a WinForm and it is located in the #pragma endregion part of my code (BTW This is Visual C++). As always I will apperciate any help or suggestions. Thanks!
It appears you’ve made this a free function rather than a member function of your class. Place this definition inside your class’ definition (probably under the
private:access modifier) and you’ll get the behavior you expect. Also, do some reading on “scope”, as it’s a very fundamental concept and not understanding it is why you’re having this problem.