StartAdministrationVBAVBA - Code Snippets

VBA – Code Snippets


I am still using ACCESS 2003 to run my office as this is the most versatile programming / DB combination, extremely stable, client-server + replicable and very fast to program.  after ACCESS 2007 the programm turned instable and stalls again and again.

Since 2003 many new feature came into existence that I have to program “around” or implement myself. Here I am contributing to public domain.


Email-Issues regarding Charsets, ……

because I often dont remember the proper function names I created 3 similar wrapping functions

Function Ascii2HTML(ByVal s As String) As String
  Ascii2HTML = UnicodeToISO_8859_1(s)
End Function

Function Ascii2Unicode(ByVal s As String) As String
  Ascii2Unicode = UnicodeToISO_8859_1(s)
End Function

Function HTML2Ascii(ByVal s As String) As String ‘utf, unicode, Ansii
   HTML2Ascii = UnicodeToISO_8859_1(s)
End Function


Function UnicodeToISO_8859_1(ByVal Text As String) As String
Dim objStream As Object
Const adTypeBinary = 1
Const adTypeText = 2

On Error GoTo x

Set objStream = CreateObject(“ADODB.Stream”)

objStream.Type = adTypeText
objStream.Charset = “UTF-8”
‘objStream.Charset = “iso-8859-15”
‘objStream.Charset = “iso-14289-1”

‘put Text in Stream 
objStream.WriteText Text
objStream.Position = 0
‘objStream.Charset = “UTF-8”
objStream.Charset = “iso-8859-15”

objStream.Type = adTypeBinary

If err Then
UnicodeToISO_8859_1 = Null
UnicodeToISO_8859_1 = Mid(StrConv(objStream.Read, vbUnicode), 4, 10000)
End If

Exit Function
MsgBox CStr(err.Number) + ” ” + err.Description
End Function


Kommentieren Sie den Artikel

Bitte geben Sie Ihren Kommentar ein!
Bitte geben Sie hier Ihren Namen ein