日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢(xún)
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問(wèn)題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷(xiāo)解決方案
VB.NET漢字轉(zhuǎn)換詳細(xì)操作步驟介紹

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

10年積累的網(wǎng)站建設(shè)、成都網(wǎng)站制作經(jīng)驗(yàn),可以快速應(yīng)對(duì)客戶(hù)對(duì)網(wǎng)站的新想法和需求。提供各種問(wèn)題對(duì)應(yīng)的解決方案。讓選擇我們的客戶(hù)得到更好、更有力的網(wǎng)絡(luò)服務(wù)。我雖然不認(rèn)識(shí)你,你也不認(rèn)識(shí)我。但先做網(wǎng)站后付款的網(wǎng)站建設(shè)流程,更有凌河免費(fèi)網(wǎng)站建設(shè)讓你可以放心的選擇與我們合作。

下面這段VB.NET漢字轉(zhuǎn)換代碼解決了這個(gè)問(wèn)題,將其拷到宏編輯器里保存即可,寫(xiě)的有點(diǎn)傻傻的,懶得優(yōu)化了,好使就行:)

  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 單字轉(zhuǎn)換()
  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. '全部替換當(dāng)前文件的漢字
  2. Public Sub 全部轉(zhuǎn)換()
  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漢字轉(zhuǎn)換的相關(guān)代碼就為大家介紹到這里。


名稱(chēng)欄目:VB.NET漢字轉(zhuǎn)換詳細(xì)操作步驟介紹
鏈接分享:http://www.dlmjj.cn/article/djjhpgd.html