New line character in Compact Framework

mojoman

Member
Joined
Nov 21, 2006
Messages
20
Programming Experience
Beginner
Hello. Scanner project is going well. One last problem to solve, which I though I did before....

VB.NET:
[COLOR=Blue]Private Sub[/COLOR][SIZE=2] Scanner1_ScanCompleteEvent([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff] Object[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] PsionTeklogix.Barcode.ScanCompleteEventArgs)[/SIZE]
[SIZE=2]txtlastcode.Text = txtBarcode.Text[/SIZE]
[SIZE=2]txtBarcode.Text = e.Text[/SIZE]
[SIZE=2]StatusBar1.Text = [/SIZE][SIZE=2][COLOR=#800000]"Scan successful"[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Try[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] sw [/SIZE][SIZE=2][COLOR=#0000ff]As [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] System.IO.StreamWriter(sourcefile, [/SIZE][SIZE=2][COLOR=#0000ff]True[/COLOR][/SIZE][SIZE=2], System.Text.Encoding.ASCII)[/SIZE]
[SIZE=2]sw.Write(txtBarcode.Text & vbCrLf)[/SIZE]
[SIZE=2]sw.Close()[/SIZE]
[SIZE=2][COLOR=#0000ff]Catch[/COLOR][/SIZE][SIZE=2] ex [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Exception[/SIZE]
[SIZE=2]Debug.Write(ex.Message)[/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff] Try[/COLOR][/SIZE]
-------------
Text gets recorded in my data file like:
ABC DEF

I need it to be recorded as:
ABC
DEF
----
I thought adding VBCRLF would solve this problem and it did in the past but this time it does not seem to be working. ANy advice would be appreciated.
 
Last edited by a moderator:
That did not work

I did as you suggested but I still get the same problem. Scanner is running on WINDOWS CE 4.2...any other ideas? Code is now:

VB.NET:
[SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff] Sub[/COLOR][/SIZE][SIZE=2] Scanner1_ScanCompleteEvent([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff] Object[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] PsionTeklogix.Barcode.ScanCompleteEventArgs)[/SIZE]
[SIZE=2]txtlastcode.Text = txtBarcode.Text[/SIZE]
[SIZE=2]txtBarcode.Text = e.Text[/SIZE]
[SIZE=2]StatusBar1.Text = [/SIZE][SIZE=2][COLOR=#800000]"Scan successful"[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Try[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] sw [/SIZE][SIZE=2][COLOR=#0000ff]As [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] System.IO.StreamWriter(sourcefile, [/SIZE][SIZE=2][COLOR=#0000ff]True[/COLOR][/SIZE][SIZE=2], System.Text.Encoding.ASCII)[/SIZE]
[SIZE=2]sw.WriteLine(txtBarcode.Text)[/SIZE]
[SIZE=2]sw.Close()[/SIZE]
[SIZE=2][COLOR=#0000ff]Catch[/COLOR][/SIZE][SIZE=2] ex [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Exception[/SIZE]
[SIZE=2]Debug.Write(ex.Message)[/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff] Try
[/COLOR][/SIZE]


EndSub
 
Last edited by a moderator:
if the 'ABC DEF' is being returned as a single piece of text then you need to parce the text into an array using the split function and then iterate through the array writing each piece out one line at a time.
 
Back
Top