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

‘https://docs.microsoft.com/en-us/previous-versions/exchange-server/exchange-10/ms526296(v=exchg.10)

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”
objStream.Open

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

objStream.Type = adTypeBinary

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

objStream.Close
Exit Function
x:
MsgBox CStr(err.Number) + ” ” + err.Description
End Function

 

Google-ZENSUR!

Google zensiert meine Homepage ganz ordentlich, es ist mir tw. selber nicht möglich Artikel von mir bei Google zu finden. Desswegen bitte zum Newsletter anmelden und diesen an Freunde oder per Facebook teilen sowie die Suchfunktion innerhalb meiner Website verwenden. Folgen sie mir auch auf Twitter, dort kündige ich wichtige Artikel auch an.

Kommentieren Sie den Artikel

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

×