Zavrieť

Porady

Microsoft Visual Studio 2012 c++ - string pomoc

Dobrý deň začínam pracovať vo Visual Studiu 2012 v C++ takmer všetky základy už ovládam tak som chcel prejsť na vyššiu kategóriu.

Chcel by som pomocou stringu a TextBoxu alebo labelu niečo vypisovať na obrazovku a tu nastal môj problem:

časť kódu:

toto mi funguje lebo mam viac variantov vypisovať na obrazovku:

long int TDDusername = 50;
char lol [1];
lol[0]

[hore] 'p';
this->textBox1->Text


lol[0].ToString();

toto mi tiež funguje:

this->textBox1->Text = "a";
this->textBox1->Text += " ";
this->textBox1->Text += "a";
textBox1->Text = "+";

a toto mi nefunguje:

string lool = ("lool");
this->textBox1->Text = lool;
Pravidlá a tipy
  • Každý móže napísať len 1 odpoveď. Neskor mozete svoju odpoveď vylepšiť.
  • Odpoveď má priniesť riešenie na otázku, vyvarujte sa hodnotenia otázky.
  • Odpoveď má byť viac o faktoch ako o názoroch.
Dalšie pravidla a tipy
    Ak potrebujete v otázke niečo upresniť, najskôr sa spýtajte na podrobnosti.
    Koncept slúži na uloženie rozpracovanej odpovede, koncept sa zobrazuje len Vám, až kým ho nezverejníte.
    Ak máte podobnú otázku, založte Novú otázku alebo Súvisiacu otázku.
    ❤ Buďte priateľskí ❤
    Sme súčasťou jednej komunity, ktorá si chce vzájomne pomáhať, rozdieľnosť je vítaná ak neubližuje!
    Usporiadať podľa času

    Kujon je offline (nepripojený) Kujon

    Kujon
    Tu je celi kod... to v buttone v komentare je chyba

    #include <string>
    #pragma once


    namespace WindowsFormsApplication4 {


    using namespace System;
    using namespace System::ComponentModel;
    using namespace System::Collections;
    using namespace System::Windows::Forms;
    using namespace System:ata;
    using namespace System:rawing;
    using namespace std;


    /// <summary>
    /// Summary for Form1
    /// </summary>
    public ref class Form1 : public System::Windows::Forms::Form
    {
    public:
    Form1(void)
    {
    InitializeComponent();
    //
    //TODO: Add the constructor code here
    //
    }


    protected:
    /// <summary>
    /// Clean up any resources being used.
    /// </summary>
    ~Form1()
    {
    if (components)
    {
    delete components;
    }
    }
    private: System::Windows::Forms::TextBox^ textBox1;
    protected:
    private: System::Windows::Forms::Button^ button1;
    private: System::Windows::Forms::Button^ button2;
    private: System::Windows::Forms::Button^ button3;
    private: System::Windows::Forms::Button^ button4;


    private:
    /// <summary>
    /// Required designer variable.
    /// </summary>
    System::ComponentModel::Container ^components;


    #pragma region Windows Form Designer generated code
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    void InitializeComponent(void)
    {
    this->textBox1 = (gcnew System::Windows::Forms::TextBox());
    this->button1 = (gcnew System::Windows::Forms::Button());
    this->button2 = (gcnew System::Windows::Forms::Button());
    this->button3 = (gcnew System::Windows::Forms::Button());
    this->button4 = (gcnew System::Windows::Forms::Button());
    this->SuspendLayout();
    //
    // textBox1
    //
    this->textBox1->Location = System:rawing::Point(12, 12);
    this->textBox1->Name = L"textBox1";
    this->textBox1->Size = System:rawing::Size(156, 20);
    this->textBox1->TabIndex = 0;
    //
    // button1
    //
    this->button1->Location = System:rawing::Point(12, 38);
    this->button1->Name = L"button1";
    this->button1->Size = System:rawing::Size(75, 23);
    this->button1->TabIndex = 1;
    this->button1->Text = L"zmena 1";
    this->button1->UseVisualStyleBackColor = true;
    this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
    //
    // button2
    //
    this->button2->Location = System:rawing::Point(12, 67);
    this->button2->Name = L"button2";
    this->button2->Size = System:rawing::Size(75, 23);
    this->button2->TabIndex = 2;
    this->button2->Text = L"zmena 2";
    this->button2->UseVisualStyleBackColor = true;
    this->button2->Click += gcnew System::EventHandler(this, &Form1::button2_Click);
    //
    // button3
    //
    this->button3->Location = System:rawing::Point(12, 96);
    this->button3->Name = L"button3";
    this->button3->Size = System:rawing::Size(75, 23);
    this->button3->TabIndex = 3;
    this->button3->Text = L"zmena 3";
    this->button3->UseVisualStyleBackColor = true;
    this->button3->Click += gcnew System::EventHandler(this, &Form1::button3_Click);
    //
    // button4
    //
    this->button4->Location = System:rawing::Point(93, 38);
    this->button4->Name = L"button4";
    this->button4->Size = System:rawing::Size(75, 23);
    this->button4->TabIndex = 4;
    this->button4->Text = L"clear";
    this->button4->UseVisualStyleBackColor = true;
    this->button4->Click += gcnew System::EventHandler(this, &Form1::button4_Click);
    //
    // Form1
    //
    this->AutoScaleDimensions = System:rawing::SizeF(6, 13);
    this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
    this->ClientSize = System:rawing::Size(195, 135);
    this->Controls->Add(this->button4);
    this->Controls->Add(this->button3);
    this->Controls->Add(this->button2);
    this->Controls->Add(this->button1);
    this->Controls->Add(this->textBox1);
    this->Name = L"Form1";
    this->Text = L"Form1";
    this->ResumeLayout(false);
    this->PerformLayout();


    }
    #pragma endregion
    private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
    long int TDDusername = 50;
    char lol [1];
    lol[0]

    [hore] 'p';
    this->textBox1->Text


    lol[0].ToString();
    }
    private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
    this->textBox1->Text = "a";
    this->textBox1->Text += " ";
    this->textBox1->Text += "a";
    }
    private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e) {
    string lool = ("lool");
    //this->textBox1->Text = lool;
    }
    private: System::Void button4_Click(System::Object^ sender, System::EventArgs^ e) {
    this->textBox1->Text = "";
    }
    };
    }

    Microsoft Visual Studio 2012 c++ - string pomoc

    Porady, ktoré by vás mohli zaujímať

    Prihláste sa a sledujte len tie Porady, ktoré Vás zaujímajú.