Ken
Ken

Reputation: 33

How to display global variable on messagebox?

This is written code,

void horizontal_calculate()
{
    String ^aa = filenames[0];
    std::string file1(marshal_as<std::string>(aa));
    String ^bb = filenames[1];
    std::string file2(marshal_as<std::string>(bb));

    double Result3=horizontal_read(file1);
    double Result4=horizontal_read(file2);
    double result=Result3/Result4;
    result1=result;
    System::Diagnostics::Debug::WriteLine("{0}",result);
}

private: System::Void button4_Click(System::Object^  sender, System::EventArgs^  e) {


             for (int i = 0; i < filenames->Length; i++)
                 System::Diagnostics::Debug::WriteLine(filenames[i]);

             semicircle();
             horizontal_calculate();
             oblique();


             MessageBox::Show("Time Ratio = "result1"","Screening Result",MessageBoxButtons::OK, MessageBoxIcon::Information);
         } 

I have declared double=result1 as global variable.

It comes out an error "error C2146: syntax error : missing ')' before identifier 'result1'", so how am I going to solve this?

is it needed and how's the way to convert double to string?

Thanks all.

Upvotes: 0

Views: 1011

Answers (1)

Alex F
Alex F

Reputation: 43331

If the problem is in MessageBox line, write it by the following way:

MessageBox::Show(
    String::Format("Time Ratio = {0}", result1),
    "Screening Result",
    MessageBoxButtons::OK, MessageBoxIcon::Information);

Upvotes: 1

Related Questions