Excel Text Converter as C # Format

Source: Internet
Author: User

Sub SetBlueText (str_startNo As Integer, colLength As Integer)

With ActiveCell. Characters (Start: = str_startNo, Length: = colLength). Font
. Name = "too many other"
. FontStyle = "zookeeper"
. Size = 11
. Strikethrough = False
. Superscript = False
. Subscript = False
. OutlineFont = False
. Shadow = False
. Underline = xlUnderlineStyleNone
. Color =-65536
. Tintandshade = 0
. Themefont = xlthemefontminor
End

End sub

Sub setgreentext (str_startno as integer, collength as integer)

With activecell. characters (START: = str_startno, Length: = collength). Font
. Name = "too many other"
. Fontstyle = "zookeeper"
. Size = 11
. Strikethrough = false
. Superscript = false
. Subscript = false
. Outlinefont = false
. Shadow = false
. Underline = xlunderlinestylenone
. Color =-11489280
. TintAndShade = 0
. ThemeFont = xlThemeFontMinor
End
End Sub

Sub SetBlackText (str_startNo As Integer, colLength As Integer)

With ActiveCell. Characters (Start: = str_startNo, Length: = colLength). Font
. Name = "too many other"
. FontStyle = "zookeeper"
. Size = 11
. Strikethrough = False
. Superscript = False
. Subscript = False
. OutlineFont = False
. Shadow = False
. Underline = xlUnderlineStyleNone
. Color = 0
. TintAndShade = 0
. ThemeFont = xlThemeFontMinor
End
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


'===================================================== ==========================================
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

'=================================================== ==========================================
Case "S"
If startNo> 0 And Mid (str, I, 7) = "String" Then
ColLength = 7
StrStartNo = I

Call SetGreenText (strStartNo, colLength)

End If


'=================================================== ==========================================
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


'================================================= ==========================================

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

'========================================== ArrayList ==== ==========================================
Case ""
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.