Using regular code inside handler function

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hi Everybody,

I would appreciate it if you can give me a hand here.

I want to use the two codes, below, together to do the following
when the "IN" button is clicked (InBtn_Click):-

1- Create (or open) output.txt, and
2- Type the current time (hour only) in it.

I tried to include the first code inside the handle function in the second
code, but it does not work. Can anybody tell me who I am going to work the
two codes together?

Each code works fine by itself. The message box inside the
handler works fine when "IN" button is clicked. The the output.txt file
open and the current time will be stamped inside it when I use it in a
different function. But if I put the first code inside the handler function
of the second code, then, when I click the "IN" button, I would not get what
I am expecting, Which is to open output.txt and stamp the current time.

First code:

FileStream* fs = new FileStream(S"output.txt", FileMode::Create);
StreamWriter* sw = new StreamWriter(fs);
String* TimeString = System::DateTime::Now.ToString("HH");
sw->WriteLine(TimeString);
sw->Flush();
sw->Close();

Second Code:

private: System::Void InBtn_Click(System::Object * sender,
System::EventArgs * e)
{

// If I put the first code here, output.txt would not be created and current time
//would not be stamped.

if ( mark == '-')
{
MessageBox::Show(" You can't sign in twice! ",S" Error ");
}
}


--
Thanks
Allen

.



Relevant Pages

  • Re: CStdioFile - Cant read what I have just written
    ... It's hard to know what's happening just from the information you provided but if I was having this issue on my machine, I'd start by tracing through the first code to ensure everything runs correctly return true, what is your resulting filename). ... And, if that looked okay, I'd then trace through the second code and see what part of that is not working. ... I have a program that uses a text file for configuration. ... configuration is written to a text file using CStdioFile, ...
    (microsoft.public.vc.mfc)
  • How to use file I/o codes with forms and controls codes
    ... I tried to include the first code inside the handle function in the second ... But if I put the first code inside the handler function ... of the second code, then, when I click the "IN" button, I would not get what ... if (mark == '-') ...
    (microsoft.public.dotnet.framework.clr)
  • How to use file I/o codes with form and controls codes
    ... I tried to include the first code inside the handle function in the second ... But if I put the first code inside the handler function ... of the second code, then, when I click the "IN" button, I would not get what ... if (mark == '-') ...
    (microsoft.public.dotnet.framework.aspnet)
  • Date Range - error in the COM component
    ... I am using MDX Sample ... First code below works fine. ... Second code returns the error ... NON EMPTY on rows ...
    (microsoft.public.sqlserver.datawarehouse)
  • Date Range - error in the COM component
    ... I am using MDX Sample ... First code below works fine. ... Second code returns the error ... NON EMPTY on rows ...
    (microsoft.public.sqlserver.olap)