VB宏基本案例(11)
Sub chineseToCode()
Dim tmpStr, str, ss As String
Dim numCell As String
Dim tar As Range
numCell = ""
repalceText
For j = 1 To 1000
tmpStr = ""
Sheets("all").Select
Range("d" & j).Value = LCase(Range("d" & j).Value)
str = Range("a" & j).Value
If (str = "") Then
Exit For
Else
For i = 1 To Len(str)
Sheets("code").Select
Columns("A:A").Select
ss = Mid(str, i, 1)
Set tar = Selection.Find(What:=ss, After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
, SearchFormat:=False)
If tar Is Nothing Then
tmpStr = tmpStr & ss
Else
numCell = "d" & tar.Row
tmpStr = tmpStr & Sheets("code").Range(numCell)
End If
Next i
Worksheets("all").Activate
Range("g" & j).Value = tmpStr
End If
Next j
Open "C:\CG02B_CHINA\source\RB-v0101-China\application\src\app\UIManager\GUIData\chinese_str_1.h" For Output As #2
For k = 1 To 1000
If (Range("a" & k).Value = "") Then
Exit For
Else
strM = strM & chr(13) & "static const char str_" & Sheets("all").Range("d" & k).Value _
& "[]=" & chr(34) & Sheets("all").Range("g" & k).Value & chr(34) & ";"
End If
Next k
Print #2, strM
Close #2
End Sub

浙公网安备 33010602011771号