C++ Form Textbox Updates

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
hi,
    Im a bit new to Form applications in C++. Ive been messing around with Visual Studio 2005, and I am stumped with a problem. I want a textbox to display a variable that is continuously updated in a function. for example:
 
static int a;
 
Form1(void)      
{
   InitializeComponent();
   a=0;
}
static void Test()
{
    a++;  // increment the value displayed by textBox1
}
<font color="#c0c0c0" size=2>  </font>
now ive been searching far and wide for ways to do this, but i cant get the syntax right. I can get textBox1 to display the initial value of a, but it wont update a after Test() is called. Ive tried things like calling Test() from Main() and sticking it in a loop,
 
while(1)
{
    Form1:: Test();    // update textBox1
    Sleep(1000);       // wait 1 second
}
 
but then i run into my problem... updating textBox1. I cant stick any assignments in Test() without creating errors. To tell the truth, Im not even sure if Test() is updating a with the method im using. any suggestions?

View the full article
 

Similar threads

Back
Top