Visual C++ Error C2146

2019-08-18 23:44发布

everyone, I was trying to compile a program using C++/CLI to check my stocks, but I ran into an error when I put the variable in the URL. Can anyone help me, please?

private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
    this->webBrowser1->Navigate("http://finance.yahoo.com/echarts?s="num".HK+Interactive#chart1:symbol="num".hk;range=1d;indicator=volume;charttype=line;crosshair=on;ohlcvalues=0;logscale=on;source=undefined");
}

Oh, and by the way, this code is from a "Windows Forms Application" and the name of the variable is "num". Again, I would appreciate any help if possible. Thanks.

1条回答
神经病院院长
2楼-- · 2019-08-19 00:11

It looks like you aren't doing anything to build the string. I've never done managed C++, but I assume you can't do this: "http://finance.yahoo.com/echarts?s="num and get what you want. In C#, you could just use operator+: "http://finance.yahoo.com/echarts?s=" + num, or use StringBuilder, or String.Format. I'd imagine there's something similar in managed C++.

查看更多
登录 后发表回答