Gfyxer » 07.08.2003 (Чт) 12:25
для DataGrid не пробовал, а текстовом поле это так:
'======
Private Declare Function MultiByteToWideChar Lib "kernel32" (ByVal CodePage As Long, ByVal dwFlags As Long, ByVal lpMultiByteStr As String, ByVal cchMultiByte As Long, ByVal lpWideCharStr As String, ByVal cchWideChar As Long) As Long
Private Declare Function WideCharToMultiByte Lib "kernel32" (ByVal CodePage As Long, ByVal dwFlags As Long, ByVal lpWideCharStr As String, ByVal cchWideChar As Long, ByVal lpMultiByteStr As String, ByVal cchMultiByte As Long, ByVal lpDefaultChar As String, ByVal lpUsedDefaultChar As Long) As Long
Const MB_PRECOMPOSED = &H1 ' use precomposed chars
Public Function Convert(ByVal strSrc As String, ByVal nFromCP As Long, ByVal nToCP As Long) As String
'Convert(Text1.Text, 866, 1251) 'dos- >win
'Convert(Text1.Text, 1251, 866) 'win- >dos
'Convert(Text1.Text, 28595, 1251) 'iso->win
'Convert(Text1.Text, 1251, 28595) 'win->iso
'Convert(Text1.Text, 20866, 1251) 'koi8r->win
'Convert(Text1.Text, 1251, 20866) 'win->koi8r
Dim nLen As Long
Dim strDst As String
Dim strRet As String
Dim nRet As Long
nLen = Len(strSrc)
strDst = String(nLen * 2, Chr(0))
strRet = String(nLen * 2, Chr(0))
nRet = MultiByteToWideChar(nFromCP, MB_PRECOMPOSED, strSrc, nLen, strDst, nLen)
nRet = WideCharToMultiByte(nToCP, 0, strDst, nRet, strRet, nLen * 2, ByVal 0, 0)
Convert = Left(strRet, nRet)
End Function
'=======
Попробуй может будет работать и в DataGrid...