• Excel Text Converter as C# Format


    Sub SetBlueText(str_startNo As Integer, colLength As Integer)

    With ActiveCell.Characters(Start:=str_startNo, Length:=colLength).Font
                            .Name = "맑은 고딕"
                            .FontStyle = "보통"
                            .Size = 11
                            .Strikethrough = False
                            .Superscript = False
                            .Subscript = False
                            .OutlineFont = False
                            .Shadow = False
                            .Underline = xlUnderlineStyleNone
                            .Color = -65536
                            .TintAndShade = 0
                            .ThemeFont = xlThemeFontMinor
                        End With

    End Sub

    Sub SetGreenText(str_startNo As Integer, colLength As Integer)

     With ActiveCell.Characters(Start:=str_startNo, Length:=colLength).Font
                            .Name = "맑은 고딕"
                            .FontStyle = "보통"
                            .Size = 11
                            .Strikethrough = False
                            .Superscript = False
                            .Subscript = False
                            .OutlineFont = False
                            .Shadow = False
                            .Underline = xlUnderlineStyleNone
                            .Color = -11489280
                            .TintAndShade = 0
                            .ThemeFont = xlThemeFontMinor
                        End With
    End Sub

    Sub SetBlackText(str_startNo As Integer, colLength As Integer)

    With ActiveCell.Characters(Start:=str_startNo, Length:=colLength).Font
                            .Name = "맑은 고딕"
                            .FontStyle = "보통"
                            .Size = 11
                            .Strikethrough = False
                            .Superscript = False
                            .Subscript = False
                            .OutlineFont = False
                            .Shadow = False
                            .Underline = xlUnderlineStyleNone
                            .Color = 0
                            .TintAndShade = 0
                            .ThemeFont = xlThemeFontMinor
                        End With
    End Sub


    Sub SetFormat()

    Call FunctionSetFormat(3)
    Call FunctionSetFormat(4)
    Call FunctionSetFormat(5)

       
    Cells(3, 1).Select

    End Sub
    Sub FunctionSetFormat(Column As Integer)

       Dim str As String
        Dim strBool As String
        str = ""
        strBool = ""
        For m = 5 To 50 Step 1
       
        Cells(m, Column).Select
       
    '    Call SetBlueText(1, 6)
       
        Dim strFlag As String
        Dim startNo As Integer
        Dim endNo As Integer
        Dim colLength As Integer
        Dim strStartNo As Integer
       
        strFlag = ""
        startNo = 2
        colLength = 0
        strStartNo = 0
        str = ActiveCell.Text
       
            For i = 1 To Len(str)
            strBool = Mid(str, i, 1)
            Select Case strBool
              '  Case "("
                '  startNo = i
                     
              '  Case ")"
                'endNo = i
               
               
    '=================================== public =======================================
                Case "p"
                If startNo > 0 And Mid(str, 1, 6) = "public" Then
                colLength = 6
                strStartNo = 1
               
                    Call SetBlueText(strStartNo, colLength)

               End If
               
    '=================================== void =======================================
                
                Case "v"
                colLength = 5
                strStartNo = i
                If startNo > 0 And Mid(str, i, colLength) = "void " Then
                    Call SetBlueText(strStartNo, colLength)
                 End If
                
    '=================================== String =======================================
                Case "S"
                If startNo > 0 And Mid(str, i, 7) = "String " Then
                colLength = 7
                strStartNo = i
               
                    Call SetGreenText(strStartNo, colLength)

               End If
      
                
    '=================================== string =======================================
                Case "s"
                colLength = 7
                 strStartNo = i
                 If startNo > 0 And Mid(str, i, colLength) = "string " Or Mid(str, i, colLength) = "string " Then

                   Call SetBlueText(strStartNo, colLength)
                
                 End If
                
    '=================================== Boolean & BOX=======================================

               Case "B"
                colLength = 7
                strStartNo = i
                If startNo > 0 And Mid(str, i, colLength) = "Boolean" Then
                    Call SetGreenText(strStartNo, colLength)
                 End If
                
                 If Mid(str, i, 3) = "BOX" Then
                    Call SetGreenText(strStartNo, 3)
                 End If
                
                             
    '=================================== bool=======================================

               Case "b"
                colLength = 5
                strStartNo = i
                If startNo > 0 And Mid(str, i, colLength) = "bool " Then
                    Call SetBlueText(strStartNo, colLength)
                 End If

                
    '=================================== int =======================================
                
                Case "i"
                colLength = 4
                strStartNo = i
                If startNo > 0 And Mid(str, i, colLength) = "int " Then
                    Call SetBlueText(strStartNo, colLength)
                 End If
                
                             

    '=================================== ArrayList =======================================
                Case "A"
                colLength = 10
                strStartNo = i
                If startNo > 0 And Mid(str, i, colLength) = "ArrayList " Then
               
                    Call SetGreenText(strStartNo, colLength)
                     
                End If
                
                
    '=================================== IList&Int32? =======================================
                Case "I"
                colLength = 5
                strStartNo = i
                If startNo > 0 And Mid(str, i, colLength) = "IList" Then
                    Call SetGreenText(strStartNo, colLength)
                End If

               If startNo > 0 And Mid(str, i, 6) = "Int32?" Then
                    Call SetGreenText(strStartNo, 6)
                End If
                             
    '=================================== List =======================================
                Case "L"
                colLength = 5
                strStartNo = i
                If Mid(str, i - 1, colLength) = ",List" Or Mid(str, i - 1, colLength) = "(List" Or Mid(str, i - 1, colLength) = " List" Then
                    Call SetGreenText(strStartNo, colLength - 1)
                End If
                
                
    '=================================== List =======================================
                Case "H"
                colLength = 10
                strStartNo = i
                If Mid(str, i - 1, colLength) = " Hashtable" Then
                    Call SetGreenText(strStartNo, colLength - 1)
                End If
                

    '=================================== MM* =======================================
                Case "M"
               
                Dim strEntity As String
                strEntity = Mid(str, i, 21)
                strStartNo = i
               
                If startNo > 0 And Mid(str, i, 2) = "MM" Then
                     For j = 1 To 20
                        If Mid(strEntity, j, 1) = ">" Or Mid(strEntity, j, 1) = " " Then
                        colLength = j
                       
                            Call SetGreenText(strStartNo, colLength - 1)
                        j = 20
                        End If
                       
                     Next j
                     
                 End If
                


    '=================================== PALLET & PANEL =======================================
                Case "P"
                If startNo > 0 And Mid(str, i, 6) = "PALLET" Then
                colLength = 6
                strStartNo = i
               
                    Call SetGreenText(strStartNo, colLength)

               End If
               
                If Mid(str, i, 5) = "PANEL" Then
                    Call SetGreenText(strStartNo, 5)
                End If
                

           
                  
    '=================================== DateTime & DataTable & Double & DataSet======================================
                  
                Case "D"
                If Mid(str, i, 9) = "DateTime " Then
                colLength = 9
                strStartNo = i
               
                    Call SetGreenText(strStartNo, colLength)

               End If
               
                If Mid(str, i, 10) = "DataTable " Then
                strStartNo = i
                    Call SetGreenText(strStartNo, 10)
                End If
               
                'Double
               
                If Mid(str, i, 7) = "Double " Then
                strStartNo = i
                    Call SetGreenText(strStartNo, 7)
                End If
               
                If Mid(str, i, 8) = "DataSet " Then
                strStartNo = i
                    Call SetGreenText(strStartNo, 8)
                End If
               
                           
    '=================================== <*> =======================================
                Case "<"
               
                Dim strEntity2 As String
                strEntity2 = Mid(str, i, 25)
                strStartNo = i
               
                     For j = 1 To 25
                        If Mid(strEntity2, j, 1) = ">" Then
                        colLength = j
                       
                            Call SetGreenText(strStartNo + 1, colLength - 2)
                         
                        End If
                       
                     Next j


       
                Case ">"
                colLength = 2
                strStartNo = i
                If startNo > 0 And Mid(str, i, colLength) = "> " Then
                    Call SetBlackText(strStartNo, 1)
                 End If
               
              End Select
            Next i
       
        Next m
       

    End Sub

  • 相关阅读:
    Spring boot 2.0整合mybatis和druid数据源,基于starter方式
    MySQL 5.7 等高版本关于JDBC驱动的几个问题
    使用maven,包括配置阿里云镜像和eclipse的配置
    vue的学习
    Awesome Vue.js vue.js学习资源链接大全 中文
    vscode
    lombok插件安装
    Spring Boot 面试题
    Get started with Docker for Windows
    详解WebMvcConfigurer接口
  • 原文地址:https://www.cnblogs.com/kevinkim/p/2298899.html
Copyright © 2020-2023  润新知