Ok to all of you windows CSharp Gurus......
I have a simple form that I want to write to a csv file in a hand held scanner device. In the on Submit I am not sure what to write in order to create the CSV for the given data that is in the form. any help will be of great assistance.
Thanks in advance.
--------------------------------------------------------------------------------------
using
System;using
System.Collections.Generic;using
System.ComponentModel;using
System.Data;using
System.Drawing;using
System.Text;using
System.Windows.Forms;using
PsionTeklogix.Barcode;using
PsionTeklogix.Barcode.ScannerServices;namespace
Scanner_SDK_109{
public partial class Form1 : Form{
private PsionTeklogix.Barcode.Scanner scanner1; private PsionTeklogix.Barcode.ScannerServices.ScannerServicesDriver scannerServicesDriver1; public Form1(){
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e){
scanner1 =
new PsionTeklogix.Barcode.Scanner ();scannerServicesDriver1 =
new ScannerServicesDriver ();scanner1.Enabled =
true;scanner1.Driver = scannerServicesDriver1;
scanner1.ScanCompleteEvent +=
new PsionTeklogix.Barcode.ScanCompleteEventHandler(scanner1_ScanCompleteEvent);}
private void scanner1_ScanCompleteEvent(object sender, PsionTeklogix.Barcode.ScanCompleteEventArgs e){
textBox1.Text = e.Text;
textBox1.Update();
} private void button2_Click(object sender, EventArgs e){
ResetForm();
}
private void ResetForm(){
//throw new Exception("The method or operation is not implemented.");textBox1.Focus();
textBox1.Text =
"";textBox2.Text =
"";dateTimePicker1.Value =
DateTime.Now;}
private void button1_Click(object sender, EventArgs e)// Need Code Here
{
}
}
}

Simple Form writting to a csv file.
PaulSw
You'll find need to know how to write in a file: http://www.google.com/search hl=en&q=c%23+writing+to+a+file
Then you can learn the CSV file format: http://www.google.com/search hl=en&lr=&q=csv+file+format
After that everything should be simple
EmekaAwagu
Ok,
That seemed simple enough but what I need is to comma seperate it and make it so I can append the next record.
I am also woundering how I can put an incremental ID on the individual records for this file.
Here is my next iterataion.
--------------------------------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.IO;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using PsionTeklogix.Barcode;
using PsionTeklogix.Barcode.ScannerServices;
namespace Scanner_SDK_109
{
public partial class Form1 : Form
{
private PsionTeklogix.Barcode.Scanner scanner1;
private PsionTeklogix.Barcode.ScannerServices.ScannerServicesDriver scannerServicesDriver1;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
scanner1 = new PsionTeklogix.Barcode.Scanner();
scannerServicesDriver1 = new ScannerServicesDriver();
scanner1.Enabled = true;
scanner1.Driver = scannerServicesDriver1;
scanner1.ScanCompleteEvent += new PsionTeklogix.Barcode.ScanCompleteEventHandler(scanner1_ScanCompleteEvent);
}
private void scanner1_ScanCompleteEvent(object sender, PsionTeklogix.Barcode.ScanCompleteEventArgs e)
{
textBox1.Text = e.Text;
textBox1.Update();
//textBox2.Text = e.Symbology.ToString ();
//textBox2.Update();
}
private void button2_Click(object sender, EventArgs e)
{
ResetForm();
}
private void ResetForm()
{
//throw new Exception("The method or operation is not implemented.");
textBox1.Focus();
textBox1.Text = "";
textBox2.Text = "";
dateTimePicker1.Value = DateTime.Now;
}
private void button1_Click(object sender, System.EventArgs e)
{
//There need to be data here
TextWriter tw = new StreamWriter("test.txt");
tw.WriteLine(textBox1.Text);
tw.WriteLine(textBox2.Text);
tw.WriteLine(DateTime.Now);
tw.Close();
ResetForm();
}
}
}