3 Replies - 671 Views - Last Post: 11 October 2009 - 06:26 AM Rate Topic: -----

#1 owen_a  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 07-October 09

Reading and Writing

Posted 07 October 2009 - 10:22 AM

Hello All.

I've recently decided to make a simple bank application for my self but due to the fact, That I lost my work on a previous application, I've kind of forgoten the simple code for Reading and Writing From a maskedTextBox.

Basically I just need help with the part,

Writing to a Textbox without showing any...

System.Info Text: whatever i put in the masked textbox.


I've Writen code to prove that its not homework, I'm doing this, just to get my C# Abilities back again :)

using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace MyBank
{
	public partial class Form1 : Form
	{
		public Form1()
		{
			InitializeComponent();
		}

		TextWriter tw = new StreamWriter("C:\\test.txt");

		private void button1_Click(object sender, EventArgs e)
		{
			// write a line of text to the file
			tw.WriteLine("" + maskedTextBox1);

			// close the stream
			tw.Close();
		}

		private void maskedTextBox1_MaskInputRejected(object sender, MaskInputRejectedEventArgs e)
		{
			// write a line of text to the file
			tw.WriteLine("" + maskedTextBox1);

			// close the stream
			tw.Close();
		}
	}
}


Thanks....

- Owen

This post has been edited by owen_a: 07 October 2009 - 10:23 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Reading and Writing

#2 masteryee  Icon User is offline

  • D.I.C Regular

Reputation: 40
  • View blog
  • Posts: 271
  • Joined: 16-May 09

Re: Reading and Writing

Posted 07 October 2009 - 12:43 PM

Are you looking for the maskedTextBox1.Text property? Use that property to read and write the text of the text box.
Was This Post Helpful? 0
  • +
  • -

#3 owen_a  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 07-October 09

Re: Reading and Writing

Posted 11 October 2009 - 02:04 AM

View Postmasteryee, on 7 Oct, 2009 - 11:43 AM, said:

Are you looking for the maskedTextBox1.Text property? Use that property to read and write the text of the text box.


Yes, I can Write to the file, but It either shows the System.Info etc, stuff in it, and then the text i put inside the textbox, and then when i close the application it deletes everything inside the file what i told it to write.
Was This Post Helpful? 0
  • +
  • -

#4 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6075
  • View blog
  • Posts: 23,540
  • Joined: 23-August 08

Re: Reading and Writing

Posted 11 October 2009 - 06:26 AM

Read what masteryee wrote again. Pay attention.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1