# Visual Basic > Visual Basic 6 and Earlier >  Stupid Question: Is it Possible to Output a "Delta" symbol to a text file?

## daveyk021

A test program I just finished outputs its data to a CSV text file.  Excel is then used as the report generator.

Is it possible to output the "Δ" symbol to the text file?  

I am doubting it out I don't think a text file can have extended ascii in it (????)

Maybe at least some lower ascii code that Excel could change to a Δ?

----------


## Elroy

It depends on the encoding of the text file.  Get Notepad++ and then check out the encoding menu options.  Text files (and still be considered "text", and not binary) can have many combinations of ASCII, ANSI, and Unicode.  And there may or may not be beginning-of-file markers.  It's not terribly straightforward (but it's actually not too bad).

And VB6 has a bit of trouble writing anything but ASCII/ANSI files, but it can be done.

Also, I believe the regular Windows Notepad can read several encodings as well, but I don't use that much, always relying on NP++.

----------


## Elroy

Just FYI:



```

Public Sub SaveStringToUnicodeFile(sData As String, sFileSpec As String)
    ' These are typically .TXT files.  They can be read with notepad.
    Dim iFle    As Long
    Dim bb()    As Byte
    '
    iFle = FreeFile
    Open sFileSpec For Binary As iFle
    Put iFle, , &HFEFF& ' This is the Unicode header to a text file.  First byte = FF, second byte = FE.
    bb = sData
    Put iFle, , bb
    Close iFle
End Sub

Public Function LoadStringFromUnicodeFile(sFileSpec As String) As String
    ' These are typically .TXT files.  They can be read with notepad.
    Dim iFle As Long
    Dim bb() As Byte
    Dim i As Integer
    '
    iFle = FreeFile
    Open sFileSpec For Binary As iFle
    Get iFle, , i
    If i <> &HFEFF& Then ' Unicode file header.  First byte = FF, second byte = FE.
        Close iFle
        Exit Function ' It's not a valid Unicode file.
    End If
    ReDim bb(1 To LOF(iFle) - 2&)
    Get iFle, , bb
    Close iFle
    LoadStringFromUnicodeFile = bb ' This directly copies the byte array to the Unicode string (no conversion).
    ' Note: If you try to directly read the file as a string, VB6 will attempt to convert the string from ASCII to Unicode.
End Function


```

EDIT:  Those are for a specific type of Unicode text file that has the &hFEFF header in it.

----------


## Elroy

More FYI.  Run the following somehow, and it'll write out a text file with a Δ in it.



```

    Dim s As String
    s = ChrW$(&H2206)
    SaveStringToUnicodeFile s, "c:\users\elroy\desktop\temp.txt"


```

From Notepad:

----------


## dilettante

No need to avoid proper terminology.  That "header" is called a Byte Order Mark (BOM).

Minimal example:



```
    Dim F As Integer

    F = FreeFile(0)
    Open "Unicode.txt" For Binary Access Write As #F
    Put #F, , &HFEFF
    Put #F, , &H2206
    Close #F
```

----------


## dilettante

That probably isn't especially helpful in general though.

You might be better off writing text into an ADO Stream instance and then saving that to disk.  But for simple UTF-16LE it may be even easier to just use a Scripting Runtime TextSteam instance.  That was the stopgap provided with VB6 until a later VB (that we never got) reworked file I/O operations.

----------

