📄 单片机学习小工具.frm
字号:
Height = 615
Left = 420
TabIndex = 7
Top = 1200
Width = 615
End
Begin VB.Label Label4
Alignment = 2 'Center
BorderStyle = 1 'Fixed Single
Caption = "定时时长(ms)"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H000080FF&
Height = 360
Left = 420
TabIndex = 6
Top = 3060
Width = 1755
End
Begin VB.Label Label3
Alignment = 2 'Center
BorderStyle = 1 'Fixed Single
Caption = "晶振频率(MHz)"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H000080FF&
Height = 360
Left = 420
TabIndex = 5
Top = 2520
Width = 1755
End
Begin VB.Label Label2
Alignment = 2 'Center
BorderStyle = 1 'Fixed Single
Caption = "工作方式:"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H000080FF&
Height = 360
Left = 420
TabIndex = 4
Top = 2040
Width = 1755
End
End
Begin VB.Label Label15
Caption = "Label15"
Height = 375
Left = 2340
TabIndex = 57
Top = 2760
Width = 915
End
Begin VB.Image Image2
Height = 855
Left = 4080
Picture = "单片机学习小工具.frx":038A
Top = 5400
Width = 1515
End
Begin VB.Label Label12
Alignment = 2 'Center
Caption = "学好单片机没问题!"
BeginProperty Font
Name = "宋体"
Size = 21.75
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H000080FF&
Height = 495
Left = 60
TabIndex = 16
Top = 5820
Width = 4275
End
Begin VB.Label Label11
Alignment = 2 'Center
Caption = " 只要你努力! "
BeginProperty Font
Name = "宋体"
Size = 21.75
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H000080FF&
Height = 495
Left = 60
TabIndex = 14
Top = 5280
Width = 4275
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim fsxz As Long, jzxz As Single
Private Sub Combo1_Click()
Dim tt As Integer
If Combo1.ListIndex = 0 Then
fsxz = 8192
ElseIf Combo1.ListIndex = 1 Then
fsxz = 65536
ElseIf Combo1.ListIndex = 2 Then
fsxz = 256
ElseIf Combo1.ListIndex = 3 Then
tt = MsgBox("单片机在使用 方式3 定时时有特别的规定,请慎用!", 4160, "警告")
Combo1.ListIndex = 0
Text1.Text = ""
Text2.Text = ""
Label9.Caption = ""
Label10.Caption = ""
End If
End Sub
Private Sub Combo2_Click()
If Combo2.ListIndex = 0 Then
jzxz = 6
ElseIf Combo2.ListIndex = 1 Then
jzxz = 11.0592
ElseIf Combo2.ListIndex = 2 Then
jzxz = 12
End If
Text1.SetFocus
End Sub
Private Sub Command1_GotFocus()
Command1.BackColor = RGB(220, 100, 40)
Command2.BackColor = &H8000000F
Command4.BackColor = &H8000000F
Frame1.Visible = True
Frame2.Visible = False
Frame3.Visible = False
End Sub
Private Sub Command2_GotFocus()
Dim tt As Integer
tt = MsgBox("由于在做串行通信时,经常用到几个固定的波特率," + Chr(10) + "所以以表格的方式列出来,不再具体计算。" + Chr(10) + " 供大家参考!谢谢合作!", 4160, "提示")
Command2.BackColor = RGB(220, 100, 40)
Command1.BackColor = &H8000000F
Command4.BackColor = &H8000000F
Frame2.Visible = True
Frame1.Visible = False
Frame3.Visible = False
End Sub
Private Sub Command3_Click()
Dim jg As Long
Dim intt As Integer, out As Integer
Dim last As Single
out = 1
If (Combo1.Text = "") Or (Combo2.Text = "") Or (Text1.Text = "") Then
intt = MsgBox("请在输入有效值!", 4160, "警告!")
Else
If (Combo1.ListIndex = 0) And (Combo2.ListIndex = 0) Then
last = 8192 * (12 / 6) * 0.001
If (last < Val(Text1.Text)) Then
intt = MsgBox("方式0在使用6MHz晶振时的最大定时时间为:" + Str(last) + "ms", 4160, "提示")
out = 0
End If
ElseIf (Combo1.ListIndex = 0) And (Combo2.ListIndex = 1) Then
last = 8192 * (12 / 11.0592) * 0.001
If (last < Val(Text1.Text)) Then
intt = MsgBox("方式0在使用11.0592MHz晶振时的最大定时时间为:" + Str(last) + "ms", 4160, "提示")
out = 0
End If
ElseIf (Combo1.ListIndex = 0) And (Combo2.ListIndex = 2) Then
last = 8192 * (12 / 12) * 0.001
If (last < Val(Text1.Text)) Then
intt = MsgBox("方式0在使用12MHz晶振时的最大定时时间为:" + Str(last) + "ms", 4160, "提示")
out = 0
End If
ElseIf (Combo1.ListIndex = 1) And (Combo2.ListIndex = 0) Then
last = 65536 * (12 / 6) * 0.001
If (last < Val(Text1.Text)) Then
intt = MsgBox("方式1在使用6MHz晶振时的最大定时时间为:" + Str(last) + "ms", 4160, "提示")
out = 0
End If
ElseIf (Combo1.ListIndex = 1) And (Combo2.ListIndex = 1) Then
last = 65536 * (12 / 11.0592) * 0.001
If (last < Val(Text1.Text)) Then
intt = MsgBox("方式1在使用11.0592MHz晶振时的最大定时时间为:" + Str(last) + "ms", 4160, "提示")
out = 0
End If
ElseIf (Combo1.ListIndex = 1) And (Combo2.ListIndex = 2) Then
last = 65536 * (12 / 12) * 0.001
If (last < Val(Text1.Text)) Then
intt = MsgBox("方式1在使用12MHz晶振时的最大定时时间为:" + Str(last) + "ms", 4160, "提示")
out = 0
End If
ElseIf (Combo1.ListIndex = 2) And (Combo2.ListIndex = 0) Then
last = 256 * (12 / 6) * 0.001
If (last < Val(Text1.Text)) Then
intt = MsgBox("方式2在使用6MHz晶振时的最大定时时间为:" + "0" + Str(last) + "ms", 4160, "提示")
out = 0
End If
ElseIf (Combo1.ListIndex = 2) And (Combo2.ListIndex = 1) Then
last = 256 * (12 / 11.0592) * 0.001
If (last < Val(Text1.Text)) Then
intt = MsgBox("方式2在使用11.0592MHz晶振时的最大定时时间为:" + "0" + Str(last) + "ms", 4160, "提示")
out = 0
End If
ElseIf (Combo1.ListIndex = 2) And (Combo2.ListIndex = 2) Then
last = 256 * (12 / 12) * 0.001
If (last < Val(Text1.Text)) Then
intt = MsgBox("方式2在使用12MHz晶振时的最大定时时间为:" + "0" + Str(last) + "ms", 4160, "提示")
out = 0
End If
End If
If (out = 1) Then
jg = fsxz - Val(Text1.Text) * 1000 / (12 / jzxz)
Text2.Text = Trim$(Hex$(jg))
If Len(Text2.Text) = 2 Then
Text2.Text = Trim$("00" + Text2.Text + "H")
ElseIf Len(Text2.Text) = 3 Then
Text2.Text = Trim$("0" + Text2.Text + "H")
Else
Text2.Text = Trim$(Text2.Text + "H")
End If
Text2.SelStart = 0
Text2.SelLength = 2
Clipboard.SetText Text2.SelText + "H"
Label9.Caption = Clipboard.GetText()
Text2.SelStart = 2
Text2.SelLength = 2
Clipboard.SetText Text2.SelText + "H"
Label10.Caption = Clipboard.GetText()
If (Combo1.ListIndex = 2) Then
Label9.Caption = Clipboard.GetText()
End If
Else
Text1.Text = ""
Text2.Text = ""
Label9.Caption = ""
Label10.Caption = ""
End If
End If
End Sub
Private Sub Command4_Click()
Command4.BackColor = RGB(220, 100, 40)
Command2.BackColor = &H8000000F
Command1.BackColor = &H8000000F
Frame3.Visible = True
Frame2.Visible = False
Frame1.Visible = False
End Sub
Private Sub CommandButton1_Click()
End Sub
Private Sub Command5_Click()
Picture1.Visible = True
Picture2.Visible = True
Timer1.Enabled = True
Command5.Visible = False
Frame5.Visible = False
End Sub
Private Sub Form_Load()
Frame2.Left = Frame1.Left
Frame2.Top = Frame1.Top
Frame3.Left = Frame1.Left
Frame3.Top = Frame1.Top
Frame1.Visible = False
Frame2.Visible = False
Frame3.Visible = False
fsxz = -1
jzxz = -1
Text1.Text = ""
Text2.Text = ""
Label9.Caption = ""
Label10.Caption = ""
Picture1.Top = 0
Picture1.Left = 0
Picture1.Width = Form1.ScaleWidth / 2
Picture1.Height = Form1.ScaleHeight
Picture2.Top = 0
Picture2.Left = Form1.ScaleWidth / 2
Picture2.Width = Form1.ScaleWidth / 2
Picture2.Height = Form1.ScaleHeight
Frame5.Top = 0
Frame5.Left = 0
Frame5.Width = Form1.ScaleWidth
Frame5.Height = Form1.ScaleHeight
Label17.Top = 0
Label17.Left = 0
Label17.Width = Form1.ScaleWidth
Label17.Height = Form1.ScaleHeight
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
End
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Command3.Value = True
End If
End Sub
Private Sub Timer1_Timer()
If (Picture1.Width < 30) Then
Timer1.Enabled = False
Picture1.Visible = False
Picture2.Visible = False
'Frame6.Visible = False
'Frame7.Visible = False
Else
Picture1.Width = Picture1.Width - 20
'Frame6.Width = Frame6.Width - 20
Picture2.Left = Picture2.Left + 20
Picture2.Width = Picture2.Width - 15
'Frame7.Left = Frame7.Left + 20
'Frame7.Width = Frame7.Width - 15
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -