cr
|
24-01-2002 16:31 MSK
Option ExplicitEnum Code Win = 1 Dos = 2 Koi = 3 Iso = 5 End Enum Function Recode(Char As String, Src As Code, Dest As Code) As String Const wDos As String = "" Const wIso As String = "ע" Const wKoi As String = "" Const wWin As String = "" Const NotRecodedChar As String = "?" If Src = Dest Then Recode = Char Exit Function End If Dim t As String, i As Long, tt As String, a As Long, ss As String, ch As String If Src = Win Then t = Char Else Select Case Src Case Koi: ss = wKoi Case Dos: ss = wDos Case Iso: ss = wIso End Select For i = 1 To Len(Char) ch = Mid(Char, i, 1) If Asc(ch) < 128 Then t = t & ch Else a = InStr(1, ss, ch, vbBinaryCompare) If a = 0 Then t = t & NotRecodedChar Else t = t & Mid$(wWin, a, 1) End If End If Next i End If If Dest = Win Then Recode = t Else Select Case Dest Case Koi: ss = wKoi Case Dos: ss = wDos Case Iso: ss = wIso End Select For i = 1 To Len(Char) ch = Mid(t, i, 1) If Asc(ch) < 128 Then tt = tt & ch Else a = InStr(1, wWin, ch, vbBinaryCompare) If a = 0 Then tt = tt & NotRecodedChar Else tt = tt & Mid$(ss, a, 1) End If End If Next i Recode = tt End If End Function
|
cr
|
25-01-2002 09:58 MSK
Option Explicit 'To aker13 ' ' ' win, koi, dos, iso . ' : Recode (,___, _- ', _) ': Recode (text1.text, win, dos) '- (text1) win dos ' ' : ' : text1, text2, command1 ' text1 text2 : 'Text1.MultiLine = True 'Text2.MultiLine = True 'Text1.ScrollBars = 2 'Text2.ScrollBars = 2 ' . ' ' , '(text1) win koi. ' text2 ' Enum Code1 win = 1 Dos = 2 koi = 3 Iso = 5 End Enum Function Recode(Char As String, Src As Code1, Dest As Code1) As String Const wDos As String = "" Const wIso As String = "ע" Const wKoi As String = "" Const wWin As String = "" Const NotRecodedChar As String = "?" If Src = Dest Then Recode = Char Exit Function End If Dim t As String, I As Long, tt As String, a As Long, ss As String, ch As String If Src = win Then t = Char Else Select Case Src Case koi: ss = wKoi Case Dos: ss = wDos Case Iso: ss = wIso End Select For I = 1 To Len(Char) ch = Mid(Char, I, 1) If Asc(ch) < 128 Then t = t & ch Else a = InStr(1, ss, ch, vbBinaryCompare) If a = 0 Then t = t & NotRecodedChar Else t = t & Mid$(wWin, a, 1) End If End If Next I End If If Dest = win Then Recode = t Else Select Case Dest Case koi: ss = wKoi Case Dos: ss = wDos Case Iso: ss = wIso End Select For I = 1 To Len(Char) ch = Mid(t, I, 1) If Asc(ch) < 128 Then tt = tt & ch Else a = InStr(1, wWin, ch, vbBinaryCompare) If a = 0 Then tt = tt & NotRecodedChar Else tt = tt & Mid$(ss, a, 1) End If End If Next I Recode = tt End If End Function Private Sub Command1_Click() Screen.MousePointer = 11 Text2.Text = (Recode(Text1.Text, koi, win)) Screen.MousePointer = 0 End Sub Private Sub Form_Load() Text1.Text = " , koi8-r, . Recode!" Text2.Text = "" Command1.Caption = "Recode" End Sub Private Sub Form_Unload(Cancel As Integer) Dim counter As Integer Dim I As Integer counter = Me.Height Do: DoEvents counter = counter - 10 Me.Height = counter Me.Top = (Screen.Height - Me.Height) / 2 Loop Until counter <= 10 I = 15 counter = Me.Width Do: DoEvents counter = counter + I Me.Width = counter Me.Left = (Screen.Width - Me.Width) / 2 I = I + 1 Loop Until counter >= Screen.Width End End Sub
|