473,406 Members | 2,378 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How to use file I/o codes with form and controls codes


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

--
Thanks
Allen

--
Thanks
Allen

Dec 2 '07 #1
1 1120
"Allen" <al***************@yahoo.comwrote in message
news:C9**********************************@microsof t.com...
MessageBox::Show(" You can't sign in twice! ",S" Error ");

This appears to be a C++ WinForms app...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Dec 3 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: new to add-in | last post by:
In asp.net/c#, it's easy to implement Upload file to web server, just use Request.Files or Request.InputStream & runat=server form and type=file input controls. But now, it's a problem for me how...
0
by: new to add-in | last post by:
In asp.net/c#, it's easy to implement Upload file to web server, just use Request.Files or Request.InputStream & runat=server form and type=file input controls. But now, it's a problem for me how...
9
by: esakal | last post by:
Hello, I'm programming an application based on CAB infrastructure in the client side (c# .net 2005) Since my application must be sequencally, i wrote all the code in the UI thread. my...
1
by: Akinyemi | last post by:
I can manually connect controls on a Form to an Access Database through ADO. Some authors say that it is better to do the connection through codes if your database is large. I have tried to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.