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::Fo
rm
{
public:
Form1(void)
{
InitializeComponent();
}
protected:
void Dispose(Boolean disposing)
{
if (disposing && components)
{
components->Dispose();
}
__super::Dispose(disposing
);
}
private: System::Windows::Forms::La
bel * label1;
private: System::Windows::Forms::Te
xtBox * txtInputFile;
private: System::Windows::Forms::Bu
tton * btnProcess;
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Co
ntainer * 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::La
bel();
this->txtInputFile = new System::Windows::Forms::Te
xtBox();
this->btnProcess = new System::Windows::Forms::Bu
tton();
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->Locati
on = System::Drawing::Point(120
, 48);
this->txtInputFile->Name = S"txtInputFile";
this->txtInputFile->TabInd
ex = 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->
txtInputFi
le);
this->Controls->Add(this->
label1);
this->Name = S"Form1";
this->Text = S"Form1";
this->ResumeLayout(false);
}
private: System::Void btnProcess_Click(System::O
bject * 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::C
ontrol::Sh
ow' : 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::C
ontrol::Sh
ow' : 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::C
ontrol::Sh
ow' : function does not take 1 arguments
Start Free Trial