473,385 Members | 1,620 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

VC++.NET 2003 - halp - string

man
Hello,
At first I have to warn you - I'm a newbie so don't shout me down and don't
beat me :).

I have a few problems concerning programming using VC++ .NET Std 2003
(particularly Windows Forms):
1) I do not know how to take text fram a text file and paste it into a
textBox. I can do it like that:
ifstream in("teksttt.txt");

ofstream out("teksttt.txt");

string linia;

while(getline(in,linia))

asa += linia + "\n";
but then I can't paste it into textBox:
textBox1->Text = in;

It shows a problem/error:
"error C2664: 'void System::Windows::Forms::TextBox::set_Text(System::
String__gc*)' : cannot convert parameter 1 from 'std::ifstrem' to
'System::String__gc*' "

How to convert 'string' into other one to make possible pasting it into a
textBox?
What type should I use?

2) I have to paste the text like this one:
"There are n men and m women.":
"There are " + n.ToString + " men and " + m.ToString " women."
Am i right?
Thanks in advance...
man

Jul 23 '05 #1
3 1881
Le samedi 25 juin 2005 à 13:28:16, man a écrit dans comp.lang.c++*:
Hello,
At first I have to warn you - I'm a newbie so don't shout me down and don't
beat me :).
You're spoiling all the fun of it...
I have a few problems concerning programming using VC++ .NET Std 2003
(particularly Windows Forms):
1) I do not know how to take text fram a text file and paste it into a
textBox. I can do it like that:
ifstream in("teksttt.txt");

ofstream out("teksttt.txt");

string linia;

while(getline(in,linia))

asa += linia + "\n";
I assume 'asa' is a string too, right?
but then I can't paste it into textBox:
textBox1->Text = in;
Shouldn't you put the *string* in your textbox, rather than the
*stream*? Something like:

textBox1->Text = asa;

or:

textBox1->Text = asa.c_str();
It shows a problem/error:
"error C2664: 'void System::Windows::Forms::TextBox::set_Text(System::
String__gc*)' : cannot convert parameter 1 from 'std::ifstrem' to
'System::String__gc*' "


--
___________ 25/06/2005 14:20:20
_/ _ \_`_`_`_) Serge PACCALIN -- sp ad mailclub.net
\ \_L_) Il faut donc que les hommes commencent
-'(__) par n'être pas fanatiques pour mériter
_/___(_) la tolérance. -- Voltaire, 1763
Jul 23 '05 #2

"man" <pi*************@poczta.onet.pl> wrote in message
news:d9**********@news.onet.pl...
Hello,
At first I have to warn you - I'm a newbie so don't shout me down and
don't
beat me :).

I have a few problems concerning programming using VC++ .NET Std 2003
(particularly Windows Forms):
1) I do not know how to take text fram a text file and paste it into a
textBox. I can do it like that:
ifstream in("teksttt.txt");

ofstream out("teksttt.txt");

string linia;

while(getline(in,linia))

asa += linia + "\n";
but then I can't paste it into textBox:
textBox1->Text = in;

It shows a problem/error:
"error C2664: 'void System::Windows::Forms::TextBox::set_Text(System::
String__gc*)' : cannot convert parameter 1 from 'std::ifstrem' to
'System::String__gc*' "

How to convert 'string' into other one to make possible pasting it into a
textBox?
What type should I use?

2) I have to paste the text like this one:
"There are n men and m women.":
"There are " + n.ToString + " men and " + m.ToString " women."
Am i right?
Thanks in advance...
man


The problem you're having appears to be that you're trying to program
standard C++ (called unmanaged code in VC.NET) in a .NET project (managed
code). I only just started learning VC++ .NET 2003 last week, but here's
some code to help you open and read a text file and assign the data straight
to a text box:

System::IO::StreamReader* myFile;
myFile = System::IO::File::OpenText("teksttt.txt");
this->textBox1->Text = myFile->ReadLine();
ini->Close();

If you want to perform string concatenation while reading a file before
assigning it to a text box, you need the following:

System::Text::StringBuilder* linia = new System::Text::StringBuilder();

// do your file stuff here and start your loop

linia->Append(myFile->ReadLine());

// end of your loop

this->textBox1->Text = linia->ToString();

You can also do the following to replace parameters in a string with values
from variables:

linia->Append("There are {0} men and {1} women.", menvariable.ToString(),
womenvariable.ToString());

Hope this helps.

Dave
Jul 23 '05 #3
man
> Hope this helps.

Thank you very much. I'll check it up.
Dave


me :)
Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: SHC | last post by:
Hi all, I created an application from the Console Application (.NET) of VC++ .NET 2003, and I did "Build" the application of the attached .cpp file, volcanoes.xml and geology.dtd on my VC++ .NET...
0
by: Leonid | last post by:
Thanks a lot for your time! Here is WSDL: <?xml version="1.0" encoding="utf-8"?>
3
by: Binary | last post by:
VC++ .NET 2003: Access violation with /O2 compiler switch; no AV with /O Hi I'm in the process of narrowing down a problem, and I have reduced the code involved to the following If someone could...
6
by: Ben Terry | last post by:
Hello, I have a VS 2003.NET solution which consists of four c++ unmanaged legacy projects. I am adding a new project to the solution which will be in c#. What do I need to do to my c++ projects...
4
by: Alex | last post by:
Hi there I'm switching from VC++ 6.0 to VC++ .NET 2003. Since there is no stand-alone version of VC++ .NET 2003 Pro, I went and purchased the Standard version, which does not have an...
3
by: SHC | last post by:
Hi all, 1) I have used VC++.NET 2002 (v7.0) for a while. Recently I just installed VC++.NET 2003 (v7.1) - I saw the message "Settings were not migrated from Visual Studio.NET 2002 to Visual...
8
by: Edward Diener | last post by:
By reuse, I mean a function in an assembly which is called in another assembly. By a mixed-mode function I mean a function whose signature has one or more CLR types and one or more non-CLR...
14
by: Jeffrey Baker | last post by:
Hello, I wrote a program way back when VC++ 5.0 was around and when using this program in VC++ 2003 I get garbage. I was able to let the program run through code that would view the data. Since...
3
by: =?Utf-8?B?RGlwZXNoX1NoYXJtYQ==?= | last post by:
Hi all, I am porting my code in VC++ to VC.net i.e managed. I have seen somewhere that i need to convert my char* to String*, but String * doesnt perform pointer arithmetic like String* p; *p++='...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.