Нет описания
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. Imports System.IO
  2. Imports System.Text
  3. Module GOOGLE翻譯
  4. Public Class MyModule2
  5. Friend Shared Sub 執行翻譯()
  6. Dim 判斷 As Boolean : Dim strDirName As String : Dim FilePath As String
  7. If TW = True And EN = False Then : 判斷 = True : ElseIf TW = False And EN = True Then : 判斷 = False : Else
  8. 翻譯 = StrConv(翻譯, VbStrConv.TraditionalChinese, 1033)
  9. For i = 1 To Len(翻譯)
  10. If Asc(Mid(翻譯, i, 1)) < 0 Or Asc(Mid(翻譯, i, 1)) > 255 Then
  11. 判斷 = True : Exit For
  12. Else : 判斷 = False
  13. End If
  14. Next
  15. End If
  16. Dim Str2 As String = Application.StartupPath
  17. If File.Exists("A.txt") Then : File.Delete("A.txt") : ElseIf File.Exists(Str2 & "\A.txt") Then : strDirName = Str2 & "\A.txt" : End If
  18. If File.Exists("C.txt") Then : File.Delete("C.txt") : ElseIf File.Exists(Str2 & "\C.txt") Then : strDirName = Str2 & "\C.txt" : End If
  19. If File.Exists("ch.txt") Then : File.Delete("ch.txt") : ElseIf File.Exists(Str2 & "\ch.txt") Then : strDirName = Str2 & "\ch.txt" : End If
  20. If File.Exists("en.txt") Then : File.Delete("en.txt") : ElseIf File.Exists(Str2 & "\en.txt") Then : strDirName = Str2 & "\en.txt" : End If
  21. If File.Exists("in.txt") Then : File.Delete("in.txt") : ElseIf File.Exists(Str2 & "\in.txt") Then : strDirName = Str2 & "\in.txt" : End If
  22. If File.Exists(My.Computer.FileSystem.SpecialDirectories.Desktop & "\A.txt") Then : File.Delete(My.Computer.FileSystem.SpecialDirectories.Desktop & "\A.txt") : End If
  23. If File.Exists(My.Computer.FileSystem.SpecialDirectories.Desktop & "\C.txt") Then : File.Delete(My.Computer.FileSystem.SpecialDirectories.Desktop & "\C.txt") : End If
  24. If File.Exists(My.Computer.FileSystem.SpecialDirectories.Desktop & "\ch.txt") Then : File.Delete(My.Computer.FileSystem.SpecialDirectories.Desktop & "\ch.txt") : End If
  25. If File.Exists(My.Computer.FileSystem.SpecialDirectories.Desktop & "\en.txt") Then : File.Delete(My.Computer.FileSystem.SpecialDirectories.Desktop & "\en.txt") : End If
  26. If File.Exists(My.Computer.FileSystem.SpecialDirectories.Desktop & "\in.txt") Then : File.Delete(My.Computer.FileSystem.SpecialDirectories.Desktop & "\in.txt") : End If
  27. Dim utf8 As UTF8Encoding = New UTF8Encoding(False) : FilePath = "A.txt"
  28. Try
  29. Using fs As IO.FileStream = New IO.FileStream(FilePath, FileMode.Append)
  30. Using sw As StreamWriter = New StreamWriter(fs, utf8) : Dim str As String = 翻譯 : sw.Write(str) : sw.Flush() : End Using
  31. End Using
  32. Catch ex As Exception
  33. End Try
  34. If 判斷 = True Then : FilePath = "C.txt"
  35. Try
  36. Using fs As IO.FileStream = New IO.FileStream(FilePath, FileMode.Append)
  37. Using sw As StreamWriter = New StreamWriter(fs, utf8) : Dim str As String = "中文" : sw.Write(str) : sw.Flush() : End Using
  38. End Using
  39. Catch ex As Exception
  40. End Try
  41. Else : FilePath = "C.txt"
  42. Try
  43. Using fs As IO.FileStream = New IO.FileStream(FilePath, FileMode.Append)
  44. Using sw As StreamWriter = New StreamWriter(fs, utf8) : Dim str As String = "非中文" : sw.Write(str) : sw.Flush() : End Using
  45. End Using
  46. Catch ex As Exception
  47. End Try
  48. End If
  49. Shell("Tran.exe", vbNormalFocus)
  50. End Sub
  51. End Class
  52. End Module