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

📄 form1.frm

📁 这是一个很实用的小型编译器!简单实用
💻 FRM
📖 第 1 页 / 共 5 页
字号:
Static i As Integer
Static panduan_b As Boolean
Static j As Integer

panduan_b = True



For i = wordstart To length Step 1
If (myshuzu(i) >= "a" And myshuzu(i) <= "z") Or (myshuzu(i) >= "A" And myshuzu(i) <= "Z") Or myshuzu(i) = Chr(95) Or (myshuzu(i) >= "0" And myshuzu(i) <= "9") Then
Exit For
End If
Next i



If i < length Then

If Not ((myshuzu(i) >= "a" And myshuzu(i) <= "z") Or (myshuzu(i) >= "A" And myshuzu(i) <= "Z") Or myshuzu(i) = Chr(95)) Then
panduan_b = False
End If

End If



For j = length To wordstart Step -1
If (myshuzu(j) >= "a" And myshuzu(j) <= "z") Or (myshuzu(j) >= "A" And myshuzu(j) <= "Z") Or myshuzu(j) = Chr(95) Or (myshuzu(j) >= "0" And myshuzu(j) <= "9") Then
Exit For
End If
Next j

If length = 0 Then

panduan_b = False

Else

If panduan_b = True Then

For i = i To j Step 1
If Not ((myshuzu(i) >= "a" And myshuzu(i) <= "z") Or (myshuzu(i) >= "A" And myshuzu(i) <= "Z") Or myshuzu(i) = Chr(95) Or (myshuzu(i) >= "0" And myshuzu(i) <= "9")) Then

panduan_b = False

Exit For
End If
Next i

End If

End If


biaoshifu = panduan_b

End Function

Private Function shuzi(myshuzu(), wordstart As Long, length As Long)
Static i As Integer
Static panduan_s As Boolean
Dim counter1 As Integer
Dim counter2 As Integer
Dim temp As Integer
Dim counter3 As Integer
Dim counter4 As Integer

panduan_s = True



For i = wordstart To length Step 1
If (myshuzu(i) >= "a" And myshuzu(i) <= "z") Or (myshuzu(i) >= "A" And myshuzu(i) <= "Z") Or myshuzu(i) = Chr(95) Or (myshuzu(i) >= "0" And myshuzu(i) <= "9") Then
Exit For
End If
Next i

For j = length To wordstart Step -1
If (myshuzu(j) >= "a" And myshuzu(j) <= "z") Or (myshuzu(j) >= "A" And myshuzu(j) <= "Z") Or myshuzu(j) = Chr(95) Or (myshuzu(j) >= "0" And myshuzu(j) <= "9") Then
Exit For
End If
Next j


For temp = i To j Step 1
If myshuzu(temp) = "e" Or myshuzu(temp) = "E" Then
counter1 = counter1 + 1
counter3 = temp
End If
Next temp

If counter1 > 1 Then
panduan_s = False
End If


For temp = i To j Step 1
If myshuzu(temp) = Chr(46) Then
counter2 = counter2 + 1
counter4 = temp
End If
Next temp

If counter2 > 1 Then
panduan_s = False
End If

If counter3 < counter4 Then
panduan_s = False
End If


For i = i To j Step 1
If Not ((myshuzu(i) >= "0" And myshuzu(i) <= "9") Or myshuzu(i) = "e" Or myshuzu(i) = "E" Or myshuzu(i) = Chr(46)) Then
panduan_s = False

Exit For
End If
Next i

shuzi = panduan_s

End Function

Private Sub RichTextBox1_KeyPress(KeyAscii As Integer)
Dim myinput
Static mycounter As Long
Static myinputlong As Long
Dim myshuzu()
Dim i As Integer
Dim j As Long
Dim m As Long
Static length As Long
Static flag As Boolean
Static myyinhaocounter As Long
Static flagy As Boolean
Static countery As Long
Static mykey As String
Static flagg As Boolean
Static wordstart As Long
Static wordlength As Long
Static flagb As Boolean
Static flags As Boolean
Static mywordstart As Long
Static flagd As Boolean
Static counterd As Long

begin:

myinput = RichTextBox1.Text
myinputlong = Len(myinput)
ReDim myshuzu(myinputlong)


If (KeyAscii = 32 Or KeyAscii = 13 Or KeyAscii = 9) And flag = False And flagy = False And flagd = False Then '当按下的是空格或回车

'将字符串赋值给字符数组
For i = 1 To myinputlong Step 1
myshuzu(i) = Mid$(myinput, i, 1)
Next i


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


mywordstart = mycounter + 1

flagb = biaoshifu(myshuzu(), mywordstart, myinputlong)

If flagb = True Then

'改变字体颜色
m = RichTextBox1.SelStart
RichTextBox1.SelStart = mycounter
RichTextBox1.SelLength = myinputlong - mycounter
RichTextBox1.SelColor = RGB(240, 171, 5)
RichTextBox1.SelStart = m


End If


flags = shuzi(myshuzu(), mywordstart, myinputlong)

If flags = True Then

'改变字体颜色
m = RichTextBox1.SelStart
RichTextBox1.SelStart = mycounter
RichTextBox1.SelLength = myinputlong - mycounter
RichTextBox1.SelColor = RGB(36, 36, 100)
RichTextBox1.SelStart = m

End If








wordstart = mycounter + 1
For wordstart = wordstart To myinputlong Step 1

If (myshuzu(wordstart) > "a" And myshuzu(wordstart) < "z") Or (myshuzu(wordstart) > "A" And myshuzu(wordstart) < "Z") Then
Exit For
End If

Next wordstart


wordlength = myinputlong - mycounter + 1

mykey = Mid(RichTextBox1.Text, wordstart, wordlength)

flagg = guanjianzi(mykey)



If flagg = True Then

'改变字体颜色

m = RichTextBox1.SelStart
RichTextBox1.SelStart = mycounter
RichTextBox1.SelLength = myinputlong - mycounter
RichTextBox1.SelColor = RGB(45, 21, 125)
RichTextBox1.SelStart = m

End If


mycounter = myinputlong



'改变空格的颜色
m = RichTextBox1.SelStart
RichTextBox1.SelStart = mycounter
RichTextBox1.SelLength = 1
RichTextBox1.SelColor = RGB(255, 0, 0)
RichTextBox1.SelStart = m
mycounter = myinputlong




ElseIf KeyAscii = 59 And flag = False And flagy = False And flagd = False Then '当按下的是分号

'将字符串赋值给字符数组
For i = 1 To myinputlong Step 1
myshuzu(i) = Mid$(myinput, i, 1)
Next i

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


'改变标识符的颜色

mywordstart = mycounter + 1

flagb = biaoshifu(myshuzu(), mywordstart, myinputlong)

If flagb = True Then

'改变字体颜色
m = RichTextBox1.SelStart
RichTextBox1.SelStart = mycounter
RichTextBox1.SelLength = myinputlong - mycounter
RichTextBox1.SelColor = RGB(240, 171, 5)
RichTextBox1.SelStart = m


End If

'改变数字的颜色
flags = shuzi(myshuzu(), mywordstart, myinputlong)

If flags = True Then

'改变字体颜色
m = RichTextBox1.SelStart
RichTextBox1.SelStart = mycounter
RichTextBox1.SelLength = myinputlong - mycounter
RichTextBox1.SelColor = RGB(36, 36, 100)
RichTextBox1.SelStart = m

End If

'改变关键字的颜色

wordstart = mycounter + 1
For wordstart = wordstart To myinputlong Step 1

If (myshuzu(wordstart) > "a" And myshuzu(wordstart) < "z") Or (myshuzu(wordstart) > "A" And myshuzu(wordstart) < "Z") Then
Exit For
End If

Next wordstart


wordlength = myinputlong - mycounter + 1

mykey = Mid(RichTextBox1.Text, wordstart, wordlength)

flagg = guanjianzi(mykey)



If flagg = True Then

'改变字体颜色

m = RichTextBox1.SelStart
RichTextBox1.SelStart = mycounter
RichTextBox1.SelLength = myinputlong - mycounter
RichTextBox1.SelColor = RGB(45, 21, 125)
RichTextBox1.SelStart = m

End If





mycounter = myinputlong

'改变;的颜色
m = RichTextBox1.SelStart
RichTextBox1.SelStart = mycounter
RichTextBox1.SelLength = 1
RichTextBox1.SelColor = RGB(0, 0, 255)
RichTextBox1.SelStart = m
mycounter = myinputlong + 1








ElseIf KeyAscii = 44 And flag = False And flagy = False And flagd = False Then '当按下的是逗号

'将字符串赋值给字符数组
For i = 1 To myinputlong Step 1
myshuzu(i) = Mid$(myinput, i, 1)
Next i

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


'改变标识符的颜色

mywordstart = mycounter + 1

flagb = biaoshifu(myshuzu(), mywordstart, myinputlong)

If flagb = True Then

'改变字体颜色
m = RichTextBox1.SelStart
RichTextBox1.SelStart = mycounter
RichTextBox1.SelLength = myinputlong - mycounter
RichTextBox1.SelColor = RGB(240, 171, 5)
RichTextBox1.SelStart = m


End If

'改变数字的颜色
flags = shuzi(myshuzu(), mywordstart, myinputlong)

If flags = True Then

'改变字体颜色
m = RichTextBox1.SelStart
RichTextBox1.SelStart = mycounter
RichTextBox1.SelLength = myinputlong - mycounter
RichTextBox1.SelColor = RGB(36, 36, 100)
RichTextBox1.SelStart = m

End If

'改变关键字的颜色

wordstart = mycounter + 1
For wordstart = wordstart To myinputlong Step 1

If (myshuzu(wordstart) > "a" And myshuzu(wordstart) < "z") Or (myshuzu(wordstart) > "A" And myshuzu(wordstart) < "Z") Then
Exit For
End If

Next wordstart


wordlength = myinputlong - mycounter + 1

mykey = Mid(RichTextBox1.Text, wordstart, wordlength)

flagg = guanjianzi(mykey)



If flagg = True Then

'改变字体颜色

m = RichTextBox1.SelStart
RichTextBox1.SelStart = mycounter
RichTextBox1.SelLength = myinputlong - mycounter
RichTextBox1.SelColor = RGB(45, 21, 125)
RichTextBox1.SelStart = m

End If





mycounter = myinputlong

'改变,的颜色
m = RichTextBox1.SelStart
RichTextBox1.SelStart = mycounter
RichTextBox1.SelLength = 1
RichTextBox1.SelColor = RGB(0, 0, 255)
RichTextBox1.SelStart = m
mycounter = myinputlong + 1















ElseIf KeyAscii = 123 And flag = False And flagy = False And flagd = False Then '当按下的是左大括号

'将字符串赋值给字符数组
For i = 1 To myinputlong Step 1
myshuzu(i) = Mid$(myinput, i, 1)
Next i


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

'改变标识符的颜色

mywordstart = mycounter + 1

flagb = biaoshifu(myshuzu(), mywordstart, myinputlong)

If flagb = True Then

'改变字体颜色
m = RichTextBox1.SelStart
RichTextBox1.SelStart = mycounter
RichTextBox1.SelLength = myinputlong - mycounter
RichTextBox1.SelColor = RGB(240, 171, 5)
RichTextBox1.SelStart = m


End If

'改变数字的颜色
flags = shuzi(myshuzu(), mywordstart, myinputlong)

If flags = True Then

'改变字体颜色
m = RichTextBox1.SelStart
RichTextBox1.SelStart = mycounter
RichTextBox1.SelLength = myinputlong - mycounter
RichTextBox1.SelColor = RGB(36, 36, 100)
RichTextBox1.SelStart = m

End If

'改变关键字的颜色

wordstart = mycounter + 1
For wordstart = wordstart To myinputlong Step 1

If (myshuzu(wordstart) > "a" And myshuzu(wordstart) < "z") Or (myshuzu(wordstart) > "A" And myshuzu(wordstart) < "Z") Then
Exit For
End If

Next wordstart


wordlength = myinputlong - mycounter + 1

mykey = Mid(RichTextBox1.Text, wordstart, wordlength)

flagg = guanjianzi(mykey)



If flagg = True Then

'改变字体颜色

m = RichTextBox1.SelStart
RichTextBox1.SelStart = mycounter
RichTextBox1.SelLength = myinputlong - mycounter
RichTextBox1.SelColor = RGB(45, 21, 125)
RichTextBox1.SelStart = m

End If

mycounter = myinputlong



'改变{的颜色
m = RichTextBox1.SelStart
RichTextBox1.SelStart = mycounter
RichTextBox1.SelLength = 1
RichTextBox1.SelColor = RGB(0, 0, 255)
RichTextBox1.SelStart = m
mycounter = myinputlong + 1



ElseIf KeyAscii = 125 And flag = False And flagy = False And flagd = False Then '当按下的是右大括号

'将字符串赋值给字符数组
For i = 1 To myinputlong Step 1
myshuzu(i) = Mid$(myinput, i, 1)
Next i

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


'改变标识符的颜色
mywordstart = mycounter + 1

flagb = biaoshifu(myshuzu(), mywordstart, myinputlong)

If flagb = True Then

'改变字体颜色
m = RichTextBox1.SelStart
RichTextBox1.SelStart = mycounter
RichTextBox1.SelLength = myinputlong - mycounter
RichTextBox1.SelColor = RGB(240, 171, 5)
RichTextBox1.SelStart = m


End If

 '改变数字的颜色
 
flags = shuzi(myshuzu(), mywordstart, myinputlong)

If flags = True Then

'改变字体颜色
m = RichTextBox1.SelStart
RichTextBox1.SelStart = mycounter
RichTextBox1.SelLength = myinputlong - mycounter
RichTextBox1.SelColor = RGB(36, 36, 100)
RichTextBox1.SelStart = m

End If

'改变关键字的颜色
wordstart = mycounter + 1
For wordstart = wordstart To myinputlong Step 1

If (myshuzu(wordstart) > "a" And myshuzu(wordstart) < "z") Or (myshuzu(wordstart) > "A" And myshuzu(wordstart) < "Z") Then
Exit For
End If

Next wordstart


wordlength = myinputlong - mycounter + 1

mykey = Mid(RichTextBox1.Text, wordstart, wordlength)

flagg = guanjianzi(mykey)



If flagg = True Then

'改变字体颜色

m = RichTextBox1.SelStart
RichTextBox1.SelStart = mycounter
RichTextBox1.SelLength = myinputlong - mycounter
RichTextBox1.SelColor = RGB(45, 21, 125)
RichTextBox1.SelStart = m

End If

mycounter = myinputlong



'改变}的颜色
m = RichTextBox1.SelStart
RichTextBox1.SelStart = mycounter
RichTextBox1.SelLength = 1
RichTextBox1.SelColor = RGB(0, 0, 255)
RichTextBox1.SelStart = m
mycounter = myinputlong + 1











⌨️ 快捷键说明

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