?? comdnc.frm
字號:
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Begin VB.Form Form1
Caption = "Mashin 03A 通訊程序V1.0 "
ClientHeight = 3495
ClientLeft = 45
ClientTop = 330
ClientWidth = 8085
FillColor = &H00404040&
LinkTopic = "Form1"
ScaleHeight = 3495
ScaleWidth = 8085
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command5
Caption = "接受程序"
Height = 375
Left = 4080
TabIndex = 10
Top = 2640
Width = 1455
End
Begin VB.CommandButton Command4
Caption = "調(diào)入程序"
Height = 372
Left = 4200
TabIndex = 7
Top = 1080
Width = 1212
End
Begin VB.TextBox Text3
Height = 372
Left = 4080
TabIndex = 6
Text = "Text3"
Top = 480
Width = 1452
End
Begin VB.TextBox Text2
Height = 612
Left = 360
MultiLine = -1 'True
TabIndex = 4
Text = "comdnc.frx":0000
Top = 1680
Width = 6972
End
Begin VB.CommandButton Command3
Caption = "發(fā)送程序"
Height = 372
Left = 1680
TabIndex = 3
Top = 2640
Width = 1572
End
Begin VB.CommandButton Command2
Caption = "使用COM2"
Height = 372
Left = 1920
TabIndex = 2
Top = 1080
Width = 1332
End
Begin VB.CommandButton Command1
Caption = "使用COM1"
Height = 372
Left = 360
TabIndex = 1
Top = 1080
Width = 1332
End
Begin VB.TextBox Text1
Height = 372
Left = 360
TabIndex = 0
Text = "Text1"
Top = 480
Width = 3252
End
Begin MSCommLib.MSComm MSComm1
Left = 720
Top = 2640
_ExtentX = 794
_ExtentY = 794
_Version = 393216
DTREnable = -1 'True
End
Begin VB.Label Label4
Caption = "Copyright V1.0"
BeginProperty Font
Name = "宋體"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = -1 'True
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 6120
TabIndex = 9
Top = 2880
Width = 1935
End
Begin VB.Label Label3
Caption = "通訊協(xié)議"
Height = 252
Left = 840
TabIndex = 8
Top = 240
Width = 1092
End
Begin VB.Label Label1
Caption = "文件長度"
Height = 252
Left = 4320
TabIndex = 5
Top = 240
Width = 1092
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim filebuf, linestr As String
Dim flag, point1, counter As Long
Dim aaa, bbb As String
Private Sub Command1_Click()
Text1.Text = "通訊協(xié)議:COM1,9600,n,8,1"
If MSComm1.PortOpen = True Then
MSComm1.PortOpen = False
End If
Text1.Text = "通訊協(xié)議:COM1,9600,n,8,1"
MSComm1.CommPort = 1
MSComm1.Settings = "9600,N,8,1"
MSComm1.InputLen = 1
MSComm1.InBufferSize = 1
MSComm1.RThreshold = 1
MSComm1.InputMode = comInputModeText
MSComm1.OutBufferSize = 1
MSComm1.SThreshold = 1
MSComm1.Handshaking = comNone
MSComm1.PortOpen = True
End Sub
Private Sub Command2_Click()
Text1.Text = "通訊協(xié)議:COM2,9600,n,8,1"
If MSComm1.PortOpen = True Then
MSComm1.PortOpen = False
End If
MSComm1.CommPort = 2
MSComm1.Settings = "9600,N,8,1"
MSComm1.InputLen = 1
MSComm1.InBufferSize = 1
MSComm1.RThreshold = 1
MSComm1.InputMode = comInputModeText
MSComm1.OutBufferSize = 1
MSComm1.SThreshold = 1
MSComm1.Handshaking = comNone
MSComm1.PortOpen = True
End Sub
Private Sub Command3_Click()
point1 = 1
flag = 1
aaa = Mid$(filebuf, point1, 1)
MSComm1.Output = aaa
Text2.Text = ""
End Sub
Private Sub Command4_Click()
filebuf = ""
Open "c:\sendfile.txt" For Input As #1
Do Until EOF(1)
Line Input #1, linestr
filebuf = filebuf + linestr + Chr(13) + Chr(10)
Loop
Close #1
Text3.Text = Str$(Len(filebuf))
End Sub
Private Sub Command5_Click()
filebuf = ""
Text2.Text = ""
End Sub
Private Sub Form_Load()
Text1.Text = "通訊協(xié)議:COM1,9600,n,8,1"
Text3.Text = "0"
Text2.Text = ""
counter = 0
MSComm1.CommPort = 1
MSComm1.Settings = "9600,N,8,1"
MSComm1.InputLen = 1
MSComm1.InBufferSize = 1
MSComm1.RThreshold = 1
MSComm1.InputMode = comInputModeText
MSComm1.OutBufferSize = 1
MSComm1.SThreshold = 1
MSComm1.Handshaking = comNone
If MSComm1.PortOpen = True Then
MSComm1.PortOpen = False
End If
MSComm1.PortOpen = True
End Sub
Private Sub MSComm1_OnComm()
Select Case MSComm1.CommEvent
Case comEvSend
point1 = point1 + 1
aaa = Mid$(filebuf, point1, 1)
MSComm1.Output = aaa
counter = counter + 1
If aaa = "&" Then
Text2.Text = filebuf
Exit Sub
End If
Case comEvReceive
bbb = MSComm1.Input
point1 = point1 + 1
counter = counter + 1
If bbb = Chr(10) Then
filebuf = filebuf + Chr(13) + Chr(10)
Else
filebuf = filebuf + bbb
End If
If bbb = "&" Then
Open "c:\receivefile.txt" For Output As #1
Print #1, filebuf
Text3.Text = Str$(Len(filebuf))
Text2.Text = filebuf
Close #1
End If
End Select
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -