⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.frm

📁 这是一个很实用的小型编译器!简单实用
💻 FRM
📖 第 1 页 / 共 5 页
字号:
VERSION 5.00
Object = "{3B7C8863-D78F-101B-B9B5-04021C009402}#1.2#0"; "RICHTX32.OCX"
Begin VB.Form Form1 
   Caption         =   "编译器"
   ClientHeight    =   4935
   ClientLeft      =   165
   ClientTop       =   855
   ClientWidth     =   7395
   LinkTopic       =   "Form1"
   ScaleHeight     =   4935
   ScaleWidth      =   7395
   StartUpPosition =   3  '窗口缺省
   Begin RichTextLib.RichTextBox RichTextBox1 
      Height          =   4935
      Left            =   0
      TabIndex        =   0
      Top             =   0
      Width           =   7455
      _ExtentX        =   13150
      _ExtentY        =   8705
      _Version        =   393217
      Enabled         =   -1  'True
      ScrollBars      =   2
      TextRTF         =   $"Form1.frx":0000
   End
   Begin VB.Menu mnuFile 
      Caption         =   "文件(&F)"
      Begin VB.Menu mnuFileNew 
         Caption         =   "新建(&N)"
         Index           =   1
      End
      Begin VB.Menu mnuFileOpen 
         Caption         =   "打开(&O)"
         Index           =   2
      End
      Begin VB.Menu mnuFileExit 
         Caption         =   "关闭(&X)"
         Index           =   3
      End
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Private Sub Form_Load()
RichTextBox1.Text = ""
End Sub

Private Sub mnuFileExit_Click(Index As Integer)
Unload Form1
End Sub

Private Sub mnuFileNew_Click(Index As Integer)
RichTextBox1.Text = ""
End Sub

Private Sub mnuFileOpen_Click(Index As Integer)

Dim filename As String
Dim filenumber As Integer
Dim filelength As Long
Dim filetext As String



Static myfileshuzu()


Dim i As Long
Dim wordstart As Long
Dim wordlength As Long
Dim mykey As String
Dim mycounter As Long
Dim filewordstart As Long
Dim filewordlength As Long


Static flagb As Boolean
Static flagg As Boolean
Static flags As Boolean



Static flagy As Boolean
Static flagd As Boolean
Static flag As Boolean
Dim counterd As Integer
Dim countery As Integer






filename = InputBox("请输入文件名:", "打开文件", "e:\text.txt")

filenumber = FreeFile


filelength = FileLen(filename)

Open filename For Input As filenumber

filetext = Input(filelength, filenumber)

Close filenumber

ReDim myfileshuzu(filelength)


For i = 1 To filelength Step 1

myfileshuzu(i) = Mid$(filetext, i, 1)

Next i

RichTextBox1.Text = filetext




For filewordlength = 1 To filelength Step 1








'当检查到空格或回车时

If (myfileshuzu(filewordlength) = Chr(32) Or myfileshuzu(filewordlength) = Chr(13) Or myfileshuzu(filewordlength) = Chr(9)) And flag = False And flagy = False And flagd = False Then


'改变字体颜色
m = RichTextBox1.SelStart
RichTextBox1.SelStart = mycounter
RichTextBox1.SelLength = filewordlength - mycounter
RichTextBox1.SelColor = RGB(255, 0, 0)
RichTextBox1.SelStart = m



wordstart = mycounter + 1

For wordstart = wordstart To filewordlength Step 1
If (myfileshuzu(wordstart) >= "a" And myfileshuzu(wordstart) <= "z") Or (myfileshuzu(wordstart) >= "A" And myfileshuzu(wordstart) <= "Z") Or (myfileshuzu(wordstart) >= "0" And myfileshuzu(wordstart) <= "9") Then
Exit For
End If

Next wordstart


If wordstart > filewordlength Then
wordstart = filewordlength
End If


flagb = biaoshifu(myfileshuzu(), wordstart, filewordlength)


'改变表示符的颜色
If flagb = True Then

m = RichTextBox1.SelStart
RichTextBox1.SelStart = mycounter
RichTextBox1.SelLength = filewordlength - mycounter
RichTextBox1.SelColor = RGB(240, 171, 5)
RichTextBox1.SelStart = m

End If

flags = shuzi(myfileshuzu(), wordstart, filewordlength)




 '改变数字的颜色
 
If flags = True Then

m = RichTextBox1.SelStart
RichTextBox1.SelStart = mycounter
RichTextBox1.SelLength = filewordlength - mycounter
RichTextBox1.SelColor = RGB(36, 36, 100)
RichTextBox1.SelStart = m

End If

mykey = Mid$(filetext, wordstart, filewordlength - wordstart)

flagg = guanjianzi(mykey)

If flagg = True Then
m = RichTextBox1.SelStart
RichTextBox1.SelStart = mycounter
RichTextBox1.SelLength = filewordlength - mycounter
RichTextBox1.SelColor = RGB(45, 21, 125)
RichTextBox1.SelStart = m

mycounter = filewordlength


End If
mycounter = filewordlength






ElseIf myfileshuzu(filewordlength) = Chr(59) And flag = False And flagy = False And flagd = False Then
'当按下的是分号


'改变字体颜色
m = RichTextBox1.SelStart
RichTextBox1.SelStart = mycounter
RichTextBox1.SelLength = filewordlength - mycounter
RichTextBox1.SelColor = RGB(255, 0, 0)
RichTextBox1.SelStart = m

wordstart = mycounter + 1

For wordstart = wordstart To filewordlength Step 1
If (myfileshuzu(wordstart) >= "a" And myfileshuzu(wordstart) <= "z") Or (myfileshuzu(wordstart) >= "A" And myfileshuzu(wordstart) <= "Z") Or (myfileshuzu(wordstart) >= "0" And myfileshuzu(wordstart) <= "9") Then
Exit For
End If

Next wordstart


If wordstart > filewordlength Then
wordstart = filewordlength
End If



flagb = biaoshifu(myfileshuzu(), wordstart, filewordlength)


'改变表示符的颜色
If flagb = True Then

m = RichTextBox1.SelStart
RichTextBox1.SelStart = mycounter
RichTextBox1.SelLength = filewordlength - mycounter
RichTextBox1.SelColor = RGB(240, 171, 5)
RichTextBox1.SelStart = m

End If

flags = shuzi(myfileshuzu(), wordstart, filewordlength)




 '改变数字的颜色
 
If flags = True Then

m = RichTextBox1.SelStart
RichTextBox1.SelStart = mycounter
RichTextBox1.SelLength = filewordlength - mycounter
RichTextBox1.SelColor = RGB(36, 36, 100)
RichTextBox1.SelStart = m

End If

mykey = Mid$(filetext, wordstart, filewordlength - wordstart)

flagg = guanjianzi(mykey)

If flagg = True Then
m = RichTextBox1.SelStart
RichTextBox1.SelStart = mycounter
RichTextBox1.SelLength = filewordlength - mycounter
RichTextBox1.SelColor = RGB(45, 21, 125)
RichTextBox1.SelStart = m

mycounter = filewordlength


End If


m = RichTextBox1.SelStart
RichTextBox1.SelStart = filewordlength - 1
RichTextBox1.SelLength = 1
RichTextBox1.SelColor = RGB(0, 0, 255)
RichTextBox1.SelStart = m


mycounter = filewordlength








ElseIf myfileshuzu(filewordlength) = Chr(44) And flag = False And flagy = False And flagd = False Then '当按下的是逗号



'改变字体颜色
m = RichTextBox1.SelStart
RichTextBox1.SelStart = mycounter
RichTextBox1.SelLength = filewordlength - mycounter
RichTextBox1.SelColor = RGB(255, 0, 0)
RichTextBox1.SelStart = m



wordstart = mycounter + 1


For wordstart = wordstart To filewordlength Step 1
If (myfileshuzu(wordstart) >= "a" And myfileshuzu(wordstart) <= "z") Or (myfileshuzu(wordstart) >= "A" And myfileshuzu(wordstart) <= "Z") Or (myfileshuzu(wordstart) >= "0" And myfileshuzu(wordstart) <= "9") Then
Exit For
End If

Next wordstart


If wordstart > filewordlength Then
wordstart = filewordlength
End If



flagb = biaoshifu(myfileshuzu(), wordstart, filewordlength)


'改变表示符的颜色
If flagb = True Then

m = RichTextBox1.SelStart
RichTextBox1.SelStart = mycounter
RichTextBox1.SelLength = filewordlength - mycounter
RichTextBox1.SelColor = RGB(240, 171, 5)
RichTextBox1.SelStart = m

End If

flags = shuzi(myfileshuzu(), wordstart, filewordlength)




 '改变数字的颜色
 
If flags = True Then

m = RichTextBox1.SelStart
RichTextBox1.SelStart = mycounter
RichTextBox1.SelLength = filewordlength - mycounter
RichTextBox1.SelColor = RGB(36, 36, 100)
RichTextBox1.SelStart = m

End If

mykey = Mid$(filetext, wordstart, filewordlength - wordstart)

flagg = guanjianzi(mykey)

If flagg = True Then
m = RichTextBox1.SelStart
RichTextBox1.SelStart = mycounter
RichTextBox1.SelLength = filewordlength - mycounter
RichTextBox1.SelColor = RGB(45, 21, 125)
RichTextBox1.SelStart = m

mycounter = filewordlength


End If


m = RichTextBox1.SelStart
RichTextBox1.SelStart = filewordlength - 1
RichTextBox1.SelLength = 1
RichTextBox1.SelColor = RGB(0, 0, 255)
RichTextBox1.SelStart = m


mycounter = filewordlength






ElseIf myfileshuzu(filewordlength) = Chr(123) And flag = False And flagy = False And flagd = False Then '当按下的是左大括号


'改变字体颜色
m = RichTextBox1.SelStart
RichTextBox1.SelStart = mycounter
RichTextBox1.SelLength = filewordlength - mycounter
RichTextBox1.SelColor = RGB(255, 0, 0)
RichTextBox1.SelStart = m



wordstart = mycounter + 1

For wordstart = wordstart To filewordlength Step 1
If (myfileshuzu(wordstart) >= "a" And myfileshuzu(wordstart) <= "z") Or (myfileshuzu(wordstart) >= "A" And myfileshuzu(wordstart) <= "Z") Or (myfileshuzu(wordstart) >= "0" And myfileshuzu(wordstart) <= "9") Then
Exit For
End If

Next wordstart


If wordstart > filewordlength Then
wordstart = filewordlength
End If




flagb = biaoshifu(myfileshuzu(), wordstart, filewordlength)


'改变表示符的颜色
If flagb = True Then

m = RichTextBox1.SelStart
RichTextBox1.SelStart = mycounter
RichTextBox1.SelLength = filewordlength - mycounter
RichTextBox1.SelColor = RGB(240, 171, 5)
RichTextBox1.SelStart = m

End If

flags = shuzi(myfileshuzu(), wordstart, filewordlength)




 '改变数字的颜色
 
If flags = True Then

m = RichTextBox1.SelStart
RichTextBox1.SelStart = mycounter
RichTextBox1.SelLength = filewordlength - mycounter
RichTextBox1.SelColor = RGB(36, 36, 100)
RichTextBox1.SelStart = m

End If

mykey = Mid$(filetext, wordstart, filewordlength - wordstart)

flagg = guanjianzi(mykey)

If flagg = True Then
m = RichTextBox1.SelStart
RichTextBox1.SelStart = mycounter
RichTextBox1.SelLength = filewordlength - mycounter
RichTextBox1.SelColor = RGB(45, 21, 125)
RichTextBox1.SelStart = m

mycounter = filewordlength


End If

'改变左大括号的颜色

m = RichTextBox1.SelStart
RichTextBox1.SelStart = filewordlength - 1
RichTextBox1.SelLength = 1
RichTextBox1.SelColor = RGB(0, 0, 255)
RichTextBox1.SelStart = m


mycounter = filewordlength









ElseIf myfileshuzu(filewordlength) = Chr(125) And flag = False And flagy = False And flagd = False Then '当按下的是右大括号


'改变字体颜色
m = RichTextBox1.SelStart
RichTextBox1.SelStart = mycounter
RichTextBox1.SelLength = filewordlength - mycounter
RichTextBox1.SelColor = RGB(255, 0, 0)
RichTextBox1.SelStart = m



For wordstart = mycounter To filewordlength Step 1
If (myfileshuzu(wordstart) >= "a" And myfileshuzu(wordstart) <= "z") Or (myfileshuzu(wordstart) >= "A" And myfileshuzu(wordstart) <= "Z") Or (myfileshuzu(wordstart) >= "0" And myfileshuzu(wordstart) <= "9") Then
Exit For
End If

Next wordstart


If wordstart > filewordlength Then
wordstart = filewordlength
End If



flagb = biaoshifu(myfileshuzu(), wordstart, filewordlength)


'改变表示符的颜色
If flagb = True Then

m = RichTextBox1.SelStart
RichTextBox1.SelStart = mycounter
RichTextBox1.SelLength = filewordlength - mycounter
RichTextBox1.SelColor = RGB(240, 171, 5)
RichTextBox1.SelStart = m

End If

flags = shuzi(myfileshuzu(), wordstart, filewordlength)




 '改变数字的颜色
 
If flags = True Then

m = RichTextBox1.SelStart
RichTextBox1.SelStart = mycounter
RichTextBox1.SelLength = filewordlength - mycounter
RichTextBox1.SelColor = RGB(36, 36, 100)
RichTextBox1.SelStart = m

End If

mykey = Mid$(filetext, wordstart, filewordlength - wordstart)

flagg = guanjianzi(mykey)

If flagg = True Then
m = RichTextBox1.SelStart
RichTextBox1.SelStart = mycounter
RichTextBox1.SelLength = filewordlength - mycounter
RichTextBox1.SelColor = RGB(45, 21, 125)
RichTextBox1.SelStart = m

mycounter = filewordlength


End If


'改变右大括号的颜色

m = RichTextBox1.SelStart
RichTextBox1.SelStart = filewordlength - 1
RichTextBox1.SelLength = 1
RichTextBox1.SelColor = RGB(0, 0, 255)
RichTextBox1.SelStart = m


mycounter = filewordlength









ElseIf myfileshuzu(filewordlength) = Chr(91) And flag = False And flagy = False And flagd = False Then '当按下的是左中括号


'改变字体颜色
m = RichTextBox1.SelStart
RichTextBox1.SelStart = mycounter
RichTextBox1.SelLength = filewordlength - mycounter
RichTextBox1.SelColor = RGB(255, 0, 0)
RichTextBox1.SelStart = m



wordstart = mycounter + 1


For wordstart = wordstart To filewordlength Step 1
If (myfileshuzu(wordstart) >= "a" And myfileshuzu(wordstart) <= "z") Or (myfileshuzu(wordstart) >= "A" And myfileshuzu(wordstart) <= "Z") Or (myfileshuzu(wordstart) >= "0" And myfileshuzu(wordstart) <= "9") Then
Exit For
End If

Next wordstart


If wordstart > filewordlength Then
wordstart = filewordlength
End If




flagb = biaoshifu(myfileshuzu(), wordstart, filewordlength)


'改变表示符的颜色
If flagb = True Then

m = RichTextBox1.SelStart
RichTextBox1.SelStart = mycounter
RichTextBox1.SelLength = filewordlength - mycounter
RichTextBox1.SelColor = RGB(240, 171, 5)
RichTextBox1.SelStart = m

End If

flags = shuzi(myfileshuzu(), wordstart, filewordlength)




 '改变数字的颜色
 
If flags = True Then

m = RichTextBox1.SelStart
RichTextBox1.SelStart = mycounter
RichTextBox1.SelLength = filewordlength - mycounter
RichTextBox1.SelColor = RGB(36, 36, 100)
RichTextBox1.SelStart = m

End If

mykey = Mid$(filetext, wordstart, filewordlength - wordstart)

flagg = guanjianzi(mykey)

If flagg = True Then
m = RichTextBox1.SelStart
RichTextBox1.SelStart = mycounter
RichTextBox1.SelLength = filewordlength - mycounter
RichTextBox1.SelColor = RGB(45, 21, 125)
RichTextBox1.SelStart = m

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -