how to correct the errors?

Hi guys,

I need your help. I am using managed c++ and I have no idea how to correct the errors I have received on my error list.


Here it's the error with the each line of the code:

1
2
3
4
5
6
7
8
9
10
11
12
13
private: System::Void Button1_Click(System::Object^ sender, System::EventArgs^ e) {
       String ^six = "6.";
       array<String^> ^a = ProxyAddress->Text->Split('.');

       if (six = a->Length < 2 || String::IsNullOrEmpty(a[2]))
       {
         MessageBox::Show("strings found");
       }
       else if (! (a->Length < 2) || String::IsNullOrEmpty(a[2]))
       {
         MessageBox::Show("strings not found");
       }
     }



Errors: error C2440: '=' : cannot convert from 'bool' to 'System::String ^' <----- the error are highlighting on if six statement.

1
2
3
4
5
6
7
8
9
10
11
12
public:
  property Microsoft::VisualBasic::MsgBoxResult QuitMe
  {
    MsgBoxResult get;
    {
      return 0;
    }
    void set(MsgBoxResult value)
    {
      //QuitMe' = Value
    }
  }



Errors: error C2146: syntax error : missing ';' before identifier 'get' <------ the error are highlight on msgboxresult get; statement.

Errors: error C4430: missing type specifier - int assumed. Note: C++ does not support default-int <------- same line as above



Error: error C3900: 'MyApplication1::Form1::QuitMe::MsgBoxResult': not allowed in current scope <------- same line as above

Error 71 error C2059: syntax error : '{' <-------- the error are hightlight on '{' just after the msgboxresult get;

Error: error C2334: unexpected token(s) preceding '{'; skipping apparent function body <------ same as above

Error: error C2061: syntax error : identifier 'MsgBoxResult' <--------- the error are highlight on MsgBoxResult value statement.

Error: error C3904: 'MyApplication1::Form1::QuitMe::set': must specify 1 parameter(s) <------ same as above

Error: error C3903: 'MyApplication1::Form1::QuitMe': does not have set or get method <--------- the error are highlight on '}' at the end of the statement.



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
private: System::Void Button2_Click(System::Object^ sender, System::EventArgs^ e) {

       if (Username->Text == "" && Password->Text == "")

      {

        timer1->Interval = 10000;

        timer1->Start();

       }

       else

       {

         if (GetHTMLPage("http://www.whatismyip.com" + 
ProxyAddress->Text, AutomaticServer->Checked, 
ProxyAddress->Text, 
((Microsoft::VisualBasic::Information::IsNumeric(ProxyPorts->Text)), 
ProxyPorts->Text = 0), Username->Text, Password->Text) == "")

         {

           IPAddress->Text = IPAddress->Text;

         }

         else

         {

           IPAddress->Text = ProxyAddress->Text;

         }

       }
    }


public:
String ^GetHTMLPage(String ^URL, bool UseProxy, String ^ProxyAddress, int ProxyPort, String ^UserName, String ^PassWord)
{
  return GetHTMLPage(URL, UseProxy, ProxyAddress, ProxyPort, UserName, PassWord, "");
}

public:
String ^GetHTMLPage(String ^URL, bool UseProxy, String ^ProxyAddress, int ProxyPort, String ^UserName)
{
  return GetHTMLPage(URL, UseProxy, ProxyAddress, ProxyPort, UserName, "", "");
}

public:
String ^GetHTMLPage(String ^URL, bool UseProxy, String ^ProxyAddress, int ProxyPort)
{
  return GetHTMLPage(URL, UseProxy, ProxyAddress, ProxyPort, "", "", "");
}

public:
String ^GetHTMLPage(String ^URL, bool UseProxy, String ^ProxyAddress)
{
  return GetHTMLPage(URL, UseProxy, ProxyAddress, 0, "", "", "");
}

public:
String ^GetHTMLPage(String ^URL, bool UseProxy)
{
  return GetHTMLPage(URL, UseProxy, "", 0, "", "", "");
}

public:
String ^GetHTMLPage(String ^URL)
{
  return GetHTMLPage(URL, false, "", 0, "", "", "");
}

public:
String ^GetHTMLPage(String ^URL, bool UseProxy, String ^ProxyAddress, int ProxyPort, String ^UserName, String ^PassWord, String ^Domain)
{


    String ^sResult = "";
    try
    {
      WebResponse ^objResponse = nullptr;
      WebRequest ^objRequest = System::Net::HttpWebRequest::Create(URL);

      if (! UseProxy)
      {
        WebProxy ^oProxy = gcnew WebProxy(ProxyAddress, ProxyPort);
        if (Domain != "")
        {
          oProxy->Credentials = gcnew NetworkCredential(UserName, PassWord, Domain);
        }
        else
        {
          oProxy->Credentials = gcnew NetworkCredential(UserName, PassWord);
        }
        objRequest->Proxy = oProxy;
      }


      objRequest->Method = "GET";
      objRequest->Timeout = 120000; // 20 sec.
      objResponse = objRequest->GetResponse();

      System::IO::StreamReader ^sr = gcnew System::IO::StreamReader(objResponse->GetResponseStream(), System::Text::Encoding::UTF7);

      sResult = sr->ReadToEnd();
      sr->Close();
      // when code-execution has reached this point without
      // throwing an error, the html page is loaded which
      // means all is o.k.
      MessageBox::Show("You are connected Success");
    }
    catch (System::Exception ^ex)
    {
      MessageBox::Show("You have failed connected");
    }
    return sResult;
  }





Errors: error C2664: 'void System::Windows::Forms::Control::Text::set(System::String ^)' : cannot convert parameter 1 from 'int' to 'System::String ^' <---- the error are highlighting on if GetHTMLPage statement.



1
2
3
4
5
6
7
8
9
10
 private: System::Void Button3_Click(System::Object^ sender, System::EventArgs^ e) {
       this->Close();
       this->Close();

       Form1^ form1 = gcnew Form1();
       if (form1->LANG_fr->Checked = true)
       {
         delete this;
       }
     }




Error: error C2065: 'Form1' : undeclared identifier <------ The error are highlighting on Form1^ form1 statement.

Error: error C2065: 'form1' : undeclared identifier <------ same as above

Error: error C2061: syntax error : identifier 'Form1' <------ same as above

Error: error C2227: left of '->LANG_Arabic' must point to class/struct/union/generic type <------ the error are highlighting on if form1 statement.

Error: error C2227: left of '->Checked' must point to class/struct/union/generic type <------ same as above.
For the first error, you have used '=', the assignment operator, when I assume you want '==' the comparison operator. So instead of comparing six to a->Length, it is trying to assign something to six.
Thanks for your help Xander314, I have added the '==' in the used assignment operator in the first error that you have pointed out. However, what do you mean by instead of comparing six to a->Length, it is trying to assign something to six?

And could you also please help me with the errors as I have got on above and please could you also help me with this?



Here it is:

1
2
3
4
5
6
7
8
9
10
private: System::Void Button3_Click(System::Object^ sender, System::EventArgs^ e) {
       this->Close();
       this->Close();

       Form1^ form1 = gcnew Form1();
       if (form1->LANG_fr->Checked = true)
       {
         delete this;
       }
     }




Error: error C2653: 'Form1' : is not a class or namespace name

Error : error C2065: 'LANG_Arabic' : undeclared identifier

Error : error C2227: left of '->Checked' must point to class/struct/union/generic type



1
2
3
4
5
6
7
8
9
10
11
12
public:
	property Microsoft::VisualBasic::MsgBoxResult QuitMe
	{
		MsgBoxResult get()
		{
			return 0;
		}
		void set(MsgBoxResult value)
		{
			//QuitMe' = Value
		}
	}



Errors: error C2146: syntax error : missing ';' before identifier 'get' <------ the error are highlight on msgboxresult get; statement.

Errors: error C4430: missing type specifier - int assumed. Note: C++ does not support default-int <------- same line as above



Error: error C3900: 'MyApplication1::Form1::QuitMe::MsgBoxResult': not allowed in current scope <------- same line as above

Error 71 error C2059: syntax error : '{' <-------- the error are hightlight on '{' just after the msgboxresult get;

Error: error C2334: unexpected token(s) preceding '{'; skipping apparent function body <------ same as above

Error: error C2061: syntax error : identifier 'MsgBoxResult' <--------- the error are highlight on MsgBoxResult value statement.

Error: error C3904: 'MyApplication1::Form1::QuitMe::set': must specify 1 parameter(s) <------ same as above

Error: error C3903: 'MyApplication1::Form1::QuitMe': does not have set or get method <--------- the error are highlight on '}' at the end of the statement.

Basically, I was pointing out the difference between:
1
2
a = b; // assign b to a
a == b; // compare a and b 


Before you had used the assignment operator, which was the problem, I belive.

As for many of your other problems, I'm sorry but I have never used managed C++. The first problem was just standard C++ syntax, but I'm not sure about a lot of the other stuff here. Hopefully someone else around here has more of an idea about managed C++.

Sorry :(
Thanks for your help xander314. Please can someone help me with this?

String ^URL1 = "http://www.mysite.com/myscript.php?user=" + Form2::ComboBox1->Text + "&pass=" + Form2::TextBox1->Text;



Error: error C2227: left of '->Text' must point to class/struct/union/generic type



array<String^> ^StrArr1 = x1->Value->ToString()->Split("");

Error: error C2664: 'cli::array<Type> ^System::String::Split(...cli::array<wchar_t,dimension> ^)' : cannot convert parameter 1 from 'const char [1]' to 'wchar_t'





value1 = (key1->GetValue("Test"));

Error: error C2440: '=' : cannot convert from 'System::Object ^' to 'System::String ^'



if (QuitMe = Microsoft::VisualBasic::MsgBoxResult::Yes)

Error: error C2451: conditional expression of type 'void' is illegal





if (System::Windows::Forms::RighttoLeft::Yes)

Error: error C2451: conditional expression of type 'System::Windows::Forms::RightToLeft' is illegal

I have added the reference of system::Windows::Forms and the header in a class, but it doesn't help to solve it.




Form2::CheckBox2::Checked = Microsoft::VisualBasic::Interaction::GetSetting(Application::ProductName, "Settings", "CheckQuit", "");

Error: error C3083: 'CheckBox3': the symbol to the left of a '::' must be a type



public ref class MENUITEMINFO {

public:
int cbSize;
int fMask;
int fType;
int fState;
int wID;
int hSubMenu;
int hbmpChecked;
int hbmpUnchecked;
int dwItemData;
String ^dwTypeData;
int cch;
};

Error: error C3379: 'Project1::Form1::MENUITEMINFO' : a nested class cannot have an assembly access specifier as part of its declaration



Form1^ MainForm = gcnew Form1();
if (MainForm->MenuItem1->Checked == true)
{
delete this;
}



Error: error C2065: 'Form1' : undeclared identifier

Error: error C2065: 'MainForm' : undeclared identifier

Error: error C2061: syntax error : identifier 'Form1'

Error: error C2227: left of '->MenuItem1' must point to class/struct/union/generic type

Error: error C2227: left of '->Checked' must point to class/struct/union/generic type





I have include the form1.h file in a class, but I keep getting the same errors. It is the same for this:



private: System::Void Form2_Click(Object ^eventSender, System::EventArgs ^eventArgs) {
Form2^ myform = gcnew Form2();
myform ->ShowDialog(this);
}



And it is the same that it goes for this:



if (Form2::CheckBox1->Checked == true)
{
cmQuit::ShowDialog();
e->Cancel = true;
}



Error: error C2227: left of '->Checked' must point to class/struct/union/generic type

Error: error2352: 'System::Windows::Forms::Form::ShowDialog' : illegal call of non-static member function





Any idea how to solve them?
please can someone help??????????????????
Maybe you could look for a C++/CLI forum.
Topic archived. No new replies allowed.