成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

VB.NET漢字轉換詳細操作步驟介紹

開發 后端
我們在運用能夠VB.NET進行實際開發的過程中,會逐漸的發現,這是一個非常實用的開發語言。我們先從VB.NET漢字轉換的實現方法來解讀其中的應用概念。

VB.NET開發環境的出現,幫助開發人員實現了許多特定的功能需求。比如在對移動設備的操作方面等。VB.NET漢字轉換中若使用Reflector,而且程序中有中文字符,Reflector會用代碼表示。若反成C#,網上有很多解決方案了,而VB.NET卻找不到。VB.NET里可能更復雜些,畢竟C#還是一個完整的字符串,而VB中卻被拆成一個一個單字,然后用&連接。#t#

下面這段VB.NET漢字轉換代碼解決了這個問題,將其拷到宏編輯器里保存即可,寫的有點傻傻的,懶得優化了,好使就行:)

  1. Imports System  
  2. Imports EnvDTE  
  3. Imports EnvDTE80  
  4. Imports System.Diagnostics  
  5. Imports System.Text.
    RegularExpressions  
  6. Public Module Unicode2
    Character  
  7. '必須手工選擇到單字  
  8. Public Sub 單字轉換()  
  9. Dim doc As Document = 
    DTE.ActiveDocument  
  10. Dim docText As TextDocument 
    doc.Object  
  11. Dim selText As TextSelection 
    docText.Selection()  
  12. Dim text As String = selText.Text  
  13. Dim ch As Char = cc(text)  
  14. docText.ReplacePattern(text, ch)  
  15. End Sub 
  1. '全部替換當前文件的漢字  
  2. Public Sub 全部轉換()  
  3. Dim doc As Document = 
    DTE.ActiveDocument  
  4. Dim docText As TextDocument = 
    doc.Object  
  5. Dim selText As TextSelection = 
    docText.Selection()  
  6. selText.SelectAll()  
  7. Dim text As String = selText.Text  
  8. Dim iLength As Integer  
  9. Do  
  10. iLength = text.Length  
  11. Dim m As Text.RegularExpressions.Match  
  12. '先找“字符串”:ChrW(12345) & 
    ChrW(23456) ... & ChrW(56789)  
  13. Dim strPattern As String = 
    "(ChrW\([0-9]{5}\)\s&\s)+ChrW\([0-9]{5}\)" 
  14. m = Regex.Match(text, strPattern, 
    RegexOptions.IgnoreCase)  
  15. If m.Success Then  
  16. Dim strMatch As String = m.Value  
  17. Dim strValue As String = m.Value  
  18. texttext = text.Replace(strValue, "")  
  19. strValuestrValue = strValue.
    Replace("&", "")  
  20. strValuestrValue = strValue.
    Replace(" ", "")  
  21. strValuestrValue = strValue.
    Replace("ChrW(", "")  
  22. strValuestrValue = strValue.
    Replace(")", "")  
  23. Dim chars As Integer = 
    strValue.Length()  
  24. charschars = chars \ 5  
  25. Dim strNew As String = "" 
  26. For i As Integer = 0 To chars - 1  
  27. Dim x As String = strValue.
    Substring(i * 5, 5)  
  28. strNewstrNew = strNew & ic(x)  
  29. Next  
  30. docText.ReplacePattern(strMatch, 
    """" & strNew & """")  
  31. Else  
  32. Exit Do  
  33. End If  
  34. If Not text.Length < iLength Then  
  35. Exit Do  
  36. End If  
  37. Loop 

 

  1. selText.SelectAll()  
  2. text = selText.Text  
  3. Do  
  4. iLength = text.Length  
  5. Dim m As Text.RegularExpressions.Match  
  6. '再找單字:" & ChrW(23456) & "  
  7. Dim strPattern As String = "\""\s&\
    sChrW\([0-9]{5}\)\s&\s\"""  
  8. m = Regex.Match(text, strPattern, 
    RegexOptions.IgnoreCase)  
  9. If m.Success Then  
  10. Dim strMatch As String = m.Value  
  11. Dim strValue As String = m.Value  
  12. texttext = text.Replace(strValue, "")  
  13. strValuestrValue = strValue.Replace
    ("&", "")  
  14. strValuestrValue = strValue.Replace
    (" ", "")  
  15. strValuestrValue = strValue.Replace
    ("ChrW(", "")  
  16. strValuestrValue = strValue.Replace
    (")", "")  
  17. strValuestrValue = strValue.Replace
    ("""", "")  
  18. Dim strNew = ic(strValue)  
  19. docText.ReplacePattern(strMatch, 
    strNew)  
  20. Else  
  21. Exit Do  
  22. End If  
  23. If Not text.Length < iLength Then  
  24. Exit Do  
  25. End If  
  26. Loop 

 

  1. selText.SelectAll()  
  2. text = selText.Text  
  3. Do  
  4. iLength = text.Length  
  5. Dim m As Text.RegularExpressions.Match  
  6. '再找單字:" & ChrW(23456)  
  7. Dim strPattern As String = "\""\s&\
    sChrW\([0-9]{5}\)"
     
  8. m = Regex.Match(text, strPattern, 
    RegexOptions.IgnoreCase)  
  9. If m.Success Then  
  10. Dim strMatch As String = m.Value  
  11. Dim strValue As String = m.Value  
  12. texttext = text.Replace(strValue, "")  
  13. strValuestrValue = strValue.Replace
    ("&", "")  
  14. strValuestrValue = strValue.Replace
    (" ", "")  
  15. strValuestrValue = strValue.Replace
    ("ChrW(", "")  
  16. strValuestrValue = strValue.Replace
    (")", "")  
  17. strValuestrValue = strValue.Replace
    ("""", "")  
  18. Dim strNew = ic(strValue)  
  19. docText.ReplacePattern(strMatch, 
    strNew & """")  
  20. Else  
  21. Exit Do  
  22. End If  
  23. If Not text.Length < iLength Then  
  24. Exit Do  
  25. End If  
  26. Loop 

  1. selText.SelectAll()  
  2. text = selText.Text  
  3. Do  
  4. iLength = text.Length  
  5. Dim m As Text.Regular
    Expressions.Match  
  6. '再找單字:ChrW(23456) & "  
  7. Dim strPattern As String = 
    "ChrW\([0-9]{5}\)\s&\s\
    """  
  8. m = Regex.Match(text, strPattern, 
    RegexOptions.IgnoreCase)  
  9. If m.Success Then  
  10. Dim strMatch As String = m.Value  
  11. Dim strValue As String = m.Value  
  12. texttext = text.Replace(strValue, "")  
  13. strValuestrValue = strValue.
    Replace("&", "")  
  14. strValuestrValue = strValue.
    Replace(" ", "")  
  15. strValuestrValue = strValue.
    Replace("ChrW(", "")  
  16. strValuestrValue = strValue.
    Replace(")", "")  
  17. strValuestrValue = strValue.
    Replace("""", "")  
  18. Dim strNew = ic(strValue)  
  19. docText.ReplacePattern(strMatch, 
    """" & strNew)  
  20. Else  
  21. Exit Do  
  22. End If  
  23. If Not text.Length < iLength Then  
  24. Exit Do  
  25. End If  
  26. Loop  
  27. selText.SelectAll()  
  28. text = selText.Text  
  29. Do  
  30. iLength = text.Length  
  31. Dim m As Text.RegularExpressions.
    Match  
  32. '***單字:ChrW(23456)  
  33. Dim strPattern As String = 
    "ChrW\([0-9]{5}\)" 
  34. m = Regex.Match(text, strPattern, 
    RegexOptions.IgnoreCase)  
  35. If m.Success Then  
  36. Dim strMatch As String = m.Value  
  37. Dim strValue As String = m.Value  
  38. texttext = text.Replace(strValue, "")  
  39. strValuestrValue = strValue.
    Replace(" ", "")  
  40. strValuestrValue = strValue.
    Replace("ChrW(", "")  
  41. strValuestrValue = strValue.
    Replace(")", "")  
  42. Dim strNew = ic(strValue)  
  43. docText.ReplacePattern
    (strMatch, """" & strNew & """")  
  44. Else  
  45. Exit Do  
  46. End If  
  47. If Not text.Length < iLength Then  
  48. Exit Do  
  49. End If  
  50. Loop  
  51. End Sub  
  52. Private Function cc(ByVal 
    str As String) As Char  
  53. Dim int As Integer = CInt
    (str.Substring(5, 5))  
  54. Dim ch As Char = ChrW(int)  
  55. Return ch  
  56. End Function  
  57. Private Function ic(ByVal 
    int As Integer) As Char  
  58. Dim ch As Char = ChrW(int)  
  59. Return ch  
  60. End Function  
  61. End Module 

VB.NET漢字轉換的相關代碼就為大家介紹到這里。

責任編輯:曹凱 來源: 博客園
相關推薦

2010-01-22 14:19:38

VB.NET調用jar

2009-10-28 09:55:29

VB.NET MyCl

2009-11-10 12:42:47

VB.NET Prin

2009-10-12 15:02:51

VB.NET動態控件

2010-01-21 16:45:00

VB.NET繼承規則

2010-01-07 17:51:36

VB.NET實現Sin

2010-01-08 13:35:35

VB.NET寫Log方

2009-11-10 12:48:17

VB.NET三維模型

2010-01-08 15:03:12

VB.NET類屬性

2009-10-26 10:08:44

VB.NET工程轉換成

2010-01-08 14:14:27

VB.NET使用Fin

2010-01-14 18:22:05

VB.NET硬盤速度測

2010-01-11 14:36:43

VB.NET安裝部署

2009-10-10 16:44:52

VB.NET開發控件

2010-01-13 16:15:47

VB.NET消息隊列

2009-10-12 13:54:22

VB.NET Data

2009-10-13 17:03:55

VB.NET面向對象

2009-11-02 15:45:03

VB.NET IEnu

2010-01-07 15:18:10

VB.NET常量

2010-01-18 18:32:43

VB.NET監視啟動過
點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 亚洲风情在线观看 | 国产aⅴ精品 | 久久免费精品视频 | 欧美一级在线免费 | 国产专区视频 | 三级视频久久 | aaaa一级毛片 | 日本欧美在线视频 | 亚洲成在线观看 | 国产不卡在线观看 | 亚洲一区二区三区免费视频 | www亚洲免费国内精品 | 亚洲欧美在线一区 | 日本久久一区 | 粉嫩一区二区三区国产精品 | 欧美成人h版在线观看 | 精品久久国产 | 国产激情三区 | 午夜一区二区三区 | 韩国毛片视频 | av中文字幕在线观看 | 亚洲视频 欧美视频 | 免费激情av | 亚洲激情一区二区三区 | 免费一看一级毛片 | 欧美成年人视频在线观看 | 欧美 日韩 国产 成人 | 成年人视频在线免费观看 | 自拍偷拍av | 亚洲一区二区三区久久久 | 久久久久久国产精品免费免费男同 | 涩色视频在线观看 | 911精品美国片911久久久 | 亚洲国产一区二区视频 | 久久精品视频12 | 国产成人免费视频网站高清观看视频 | 免费国产网站 | 国产欧美在线 | 人人射人人 | 国产欧美一区二区三区久久手机版 | 欧美日本韩国一区二区 |