Advertisement

10.04.2005 at 10:36AM PDT, ID: 21583540
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.4

Need help getting application to run in Visual C++.NET

Asked by cybecks in Microsoft Visual C++.Net

Tags: , ,

Hello, I've developed a forms application using Visuall C++ .NET The users will enter data into the TextBox1 Edit box amed txtInputFile and then click on the PROCESS Button. Here is my complete code. I added the code to the btnProcess. But I cannot seem to get it to compile  clean and run. At  the bottom I listed the errors I'm getting. Can Someone help me please? Thank You...

Here is the complete code
#pragma once

#include <stdio.h>
#include <Afxwin.h>
#include <atlbase.h>
#include <Atlwin.h>


//#include <iostreamh>

namespace Travel
{
      using namespace System;
      using namespace System::ComponentModel;
      using namespace System::Collections;
      using namespace System::Windows::Forms;
      using namespace System::Data;
      using namespace System::Drawing;
      using namespace System::IO;

      /// <summary>
      /// Summary for Form1
      ///
      /// WARNING: If you change the name of this class, you will need to change the
      ///          'Resource File Name' property for the managed resource compiler tool
      ///          associated with all .resx files this class depends on.  Otherwise,
      ///          the designers will not be able to interact properly with localized
      ///          resources associated with this form.
      /// </summary>
      public __gc class Form1 : public System::Windows::Forms::Form
      {      
      public:
            Form1(void)
            {
                  InitializeComponent();
            }
 
      protected:
            void Dispose(Boolean disposing)
            {
                  if (disposing && components)
                  {
                        components->Dispose();
                  }
                  __super::Dispose(disposing);
            }
      private: System::Windows::Forms::Label *  label1;
      private: System::Windows::Forms::TextBox *  txtInputFile;
      private: System::Windows::Forms::Button *  btnProcess;

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

            /// <summary>
            /// Required method for Designer support - do not modify
            /// the contents of this method with the code editor.
            /// </summary>
            void InitializeComponent(void)
            {
                  this->label1 = new System::Windows::Forms::Label();
                  this->txtInputFile = new System::Windows::Forms::TextBox();
                  this->btnProcess = new System::Windows::Forms::Button();
                  this->SuspendLayout();
                  //
                  // label1
                  //
                  this->label1->Location = System::Drawing::Point(8, 48);
                  this->label1->Name = S"label1";
                  this->label1->TabIndex = 0;
                  this->label1->Text = S"Input Travel File:";
                  //
                  // txtInputFile
                  //
                  this->txtInputFile->Location = System::Drawing::Point(120, 48);
                  this->txtInputFile->Name = S"txtInputFile";
                  this->txtInputFile->TabIndex = 1;
                  this->txtInputFile->Text = S"textBox1";
                  //
                  // btnProcess
                  //
                  this->btnProcess->Location = System::Drawing::Point(256, 48);
                  this->btnProcess->Name = S"btnProcess";
                  this->btnProcess->TabIndex = 2;
                  this->btnProcess->Text = S"Process";
                  this->btnProcess->Click += new System::EventHandler(this, btnProcess_Click);
                  //
                  // Form1
                  //
                  this->AutoScaleBaseSize = System::Drawing::Size(5, 13);
                  this->ClientSize = System::Drawing::Size(424, 110);
                  this->Controls->Add(this->btnProcess);
                  this->Controls->Add(this->txtInputFile);
                  this->Controls->Add(this->label1);
                  this->Name = S"Form1";
                  this->Text = S"Form1";
                  this->ResumeLayout(false);

            }      
      private: System::Void btnProcess_Click(System::Object *  sender, System::EventArgs *  e)
                   {
              //UpdateData(TRUE);
   FILE *inFile, *outFile;
   char buffer[4096];
   buffer [ 4096] = '\0';

this->txtInputFile->Text = S"";
this->txtInputFile->Focus();
/* Open for read when user inputs data in the txtInputFile edit box on the form(will fail if file "data" does not exist) */
   if( (inFile  = fopen(this->txtInputFile->Text, "r" )) == NULL )
       // Should display error message in a dialog box       
         MessageBox::Show(S"The Input Travel data was not opened");
   else
     
   /* Open for write, opens travel,txt file and writes to it */
   
   if( (outFile = fopen( "travel.txt", "w" )) == NULL )
         // Should display error message in a dialog box       
         MessageBox::Show(S"The Output Travel data was not opened");
   else
     
             while(fgets(buffer, sizeof(buffer), inFile)){

                  if (strncmp(buffer, "DATA", 4) == 0)
                        fputs(buffer, outFile);
                   }
     // close the files
                       fclose(inFile);
                       fclose(outFile);
                                 // Should display  the following message in a dialog box       
                                 MessageBox::Show(S"The Output file saved is trvlhis2.txt");
    // Should close the application       
      Close();

                   }

      };
}


Here is the Error Messages

c:\Development\Form1.h(112): error C2664: 'fopen' : cannot convert parameter 1 from 'System::String __gc *' to 'const char *'
c:\Development\Form1.h(114): error C2653: 'MessageBoxA' : is not a class or namespace name
c:\Development\Form1.h(114): error C2660: 'System::Windows::Forms::Control::Show' : function does not take 1 arguments
c:\Development\Form1.h(121): error C2653: 'MessageBoxA' : is not a class or namespace name
c:\Development\Form1.h(121): error C2660: 'System::Windows::Forms::Control::Show' : function does not take 1 arguments
c:\Development\Form1.h(133): error C2653: 'MessageBoxA' : is not a class or namespace name
c:\Development\Form1.h(133): error C2660: 'System::Windows::Forms::Control::Show' : function does not take 1 arguments



Start Free Trial
 
Loading Advertisement...
 
[+][-]10.04.2005 at 10:58AM PDT, ID: 15016176

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.04.2005 at 11:21AM PDT, ID: 15016373

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10.04.2005 at 11:37AM PDT, ID: 15016510

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.04.2005 at 11:43AM PDT, ID: 15016555

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.05.2005 at 01:18AM PDT, ID: 15020024

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Microsoft Visual C++.Net
Tags: __gc, error, char
Sign Up Now!
Solution Provided By: OnegaZhang
Participating Experts: 2
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32