getting website text

Feb 10, 2018 at 9:04am
this code gets the pastebin text and puts it in a textbox. how can i make it read line by line instead of reading it all?
if i were to make my pastebin like this:
"1
2"
it reads it as "12"
i want it to read it as just 1

1
2
3
4
5
6
  using namespace System::Net;
  WebClient web;
  private: System::Void button1_Click(System::Object^  sender, 
System::EventArgs^  e) {
    textBox1->Text = web.DownloadString("http://pastebin.com/raw.php?i=fPf1NBWB");
  }
Feb 10, 2018 at 4:05pm
Consider posting this in the Windows forum, given that you're not asking about standard C++.
Feb 10, 2018 at 8:56pm
Reading it line by line is more complicated. Consider slitting the string instead.
Feb 10, 2018 at 9:54pm
what if i were to get the text from a notepad then get the text from the notepad? would that be easier to make it read line by line?
Feb 11, 2018 at 3:52am
also if that's still complicated, how do i slit the string?
Feb 11, 2018 at 8:34am
Slitting a string is the easiest.
1
2
3
4
5
6
7
8
9
10
11
System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) 
    {
      WebClient web;
      String^ buffer = web.DownloadString("http://www.cplusplus.com/forum/beginner/230330/");
      String^ sep = "\r\n";
      array<String^> ^lines = buffer->Split(sep->ToCharArray());
      if (lines->Length > 0)
        textBox1->Text = lines[0];
      else
        MessageBox::Show("Text empty");
    }
Feb 11, 2018 at 9:43pm
ohhh i didn't know it was that simple. thanks a lot!
Feb 12, 2018 at 8:30am
Yes .NET makes many things very simple.

BTW. It might not work with all websites. Many websites are compressed so the whole text is in one gigantic line.
Topic archived. No new replies allowed.