Solved

Simple C++ questions concerning Borland C++ Builder

Posted on 2008-06-14
4
661 Views
Last Modified: 2012-08-13
1. I want to make the caption of label to be "The sum is:" SUM, where SUM is an integer. Label1->Caption = "The sum is" + SUM; doesn't work..
2. How do I change line in a label caption?

(these two questions are for borland c++ builder)

Thanks
0
Comment
Question by:Chrysaor
  • 2
4 Comments
 
LVL 53

Accepted Solution

by:
Infinity08 earned 125 total points
ID: 21787695
>>  1. I want to make the caption of label to be "The sum is:" SUM, where SUM is an integer. Label1->Caption = "The sum is" + SUM; doesn't work..

Try :

        Label1->Caption = "The sum is " + IntToStr(SUM);


>> 2. How do I change line in a label caption?

Try :

        Label1->Caption = "The first line\nThe second line";

Notice the \n which starts a new line.
0
 

Author Comment

by:Chrysaor
ID: 21788121
It doesn't change the line with \n ..
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 21788162
>> It doesn't change the line with \n ..

What do you mean ? What do you see ?
0
 
LVL 2

Expert Comment

by:maggc
ID: 22441008
Write

int intValue = 5;

Label1->Caption = "text" + AnsiString(intValue);

You can define WordWrap = true for the Label so it wraps the text if it is too long to fit into the current line. Or make 2 separate labels ;)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question