大家帮看看还有问题没[em04] Const COLS = 40 Sub 生成汉字表inSheet() 'On Error GoTo err Dim i As Long Dim nrow As Long Dim ncol As Long Dim r As Long Dim ChrCode As Long Columns("A:zz").Clear Columns("A:zz").ColumnWidth = 2.5 Dim arr(0 To 999, 0 To COLS - 1) Dim arrstr(600) r = 1 For i = &H4E00 To CLng("&Hfa29") nrow = ((i - &H4E00) \ COLS) Mod 1000 ncol = (i - &H4E00) Mod COLS If nrow + ncol = 0 And i <> &H4E00 Then Cells(r, 1).Resize(1000, COLS) = arr r = r + 1000 Erase arr End If arr(nrow, ncol) = VBA.ChrW$(i) Next Cells(r, 1).Resize(1000, COLS) = arr Range(Cells(1, 1), Range("a65536").End(xlUp).Offset(0, COLS - 1)).Interior.ColorIndex = 35 End Sub Sub 生成汉字表inTXT() Dim fileno As Long fileno = FreeFile Open "汉字.txt" For Binary As #fileno Put #fileno, , VBA.CInt(&HFEFF) jj = &HFF For i = &H4E To &HFA If i = &HFA Then jj = &H29 For j = 0 To jj Put #fileno, , CByte(j) Put #fileno, , CByte(i) Next Next Close #fileno End Sub
Function IsChs(word$) As Boolean '判断是否为汉字 Dim ChrCode As Long ChrCode = CLng("&h" & Hex(AscW(word$))) If (ChrCode >= &H4E00 And ChrCode <= CLng("&H9FA5")) _ Or (ChrCode >= CLng("&HF900") And ChrCode <= CLng("&Hfa29")) Then IsChs = True End Function Sub test() Dim s As String s = "嗀" Debug.Print IsChs(s) End Sub
[此贴子已经被作者于2009-10-2 18:21:12编辑过] |