Visual Basic User's Guide > Connecting to Databases
To retrieve a record from the database and display it, the data is converted from Unicode to ANSI, and then passed on to the LoadFromMemory method of Text Control 1. As Text Control 2 just displays the RTF source code without any formatting, we can simply use the Text property to load it.
[Visual Basic 6] Private Sub GetRecord() Dim ba() As Byte, s As String ' Load RTF data and convert it to a byte array s = rs("RTF") ba = StrConv(s, vbFromUnicode) ' Display RTF data in Text Control 1 TXTextControl1.LoadFromMemory ba, 5, 0 TXTextControl1.Refresh ' Display RTF source code in Text Control 2 TXTextControl2.Text = s End Sub
The text format used in this example is RTF, which has the advantage of being accessible by most word processing programs. If this is not an issue, Text Control's binary format may be a better choice, as it is more compact and will take up less space in a database.