How to put text in labels on a form (VS2005)???

B

Bo Berglund

Reposted with a better subject line.

I am trying to port code from Delphi to C++ as described in a previous
post titled: "How to swap bytes in variables (VS2005)???"

Now I have run into a bit of a snag due to my ignorance of C++, no
doubt....
The VS2005 compiler outputs this error:

1>c:\engineering\vs2005\vstest32\vstest32\MainForm.h(119) : error
C2143: syntax error : missing ';' before '.'

And doubleclicking it brings me here:

private: System::Void btnInit_Click(System::Object^ sender,
System::EventArgs^ e) {
MainForm.lblInit.Text = "Start";

What I am trying to do is to put the text "Start" into a lable lblInit
on the form MainForm. If I remove MainForm. from the code then the
error becomes this instead:

1>c:\engineering\vs2005\vstest32\vstest32\MainForm.h(118) : error
C2228: left of '.Text' must have class/struct/union
1> type is 'System::Windows::Forms::Label ^'
1> did you intend to use '->' instead?

And I have no clue as to what this means. In VisualBasic as well as in
Delphi you specify the properties with dot notation and enter values
by assignment. Is this not possible in C++??

What does the reference to -> mean? Is this what I should do and if so
how?

Completely new to C++ as you can see....
Have programmed ANSI C for many years a long time ago though.

TIA


Bo Berglund
bo.berglund(at)nospam.telia.com
 
D

David Lowndes

1>c:\engineering\vs2005\vstest32\vstest32\MainForm.h(118) : error
C2228: left of '.Text' must have class/struct/union
1> type is 'System::Windows::Forms::Label ^'
1> did you intend to use '->' instead?

And I have no clue as to what this means. In VisualBasic as well as in
Delphi you specify the properties with dot notation and enter values
by assignment. Is this not possible in C++??

In C/C++ -> is used where you have pointer variables.

You probably just need to use:

lblInit->Text = "Start";

Dave
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top