求助,有了源程序后不能产生exe文件?
VERSION 5.00Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Begin VB.Form COMForm
BorderStyle = 3 'Fixed Dialog
Caption = "PC机与单片机串口通信"
ClientHeight = 2235
ClientLeft = 45
ClientTop = 330
ClientWidth = 6330
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2235
ScaleWidth = 6330
ShowInTaskbar = 0 'False
StartUpPosition = 3 '窗口缺省
Begin VB.Timer Timer1
Left = 5280
Top = 1680
End
Begin MSCommLib.MSComm MSComm1
Left = 2880
Top = 1440
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
DTREnable = -1 'True
End
Begin Cmdquit
Caption = "关闭程序"
Height = 435
Left = 3960
TabIndex = 3
Top = 1560
Width = 1035
End
Begin Cmdsend
Caption = "发送字符"
Height = 435
Left = 1080
TabIndex = 2
Top = 1560
Width = 1035
End
Begin VB.TextBox TextReceive
Height = 795
Left = 3270
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 1
Top = 480
Width = 3015
End
Begin VB.TextBox Textsend
Height = 795
Left = 30
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 0
Top = 450
Width = 3015
End
Begin VB.Label Label2
Caption = "显示接收字符区:"
Height = 195
Left = 3300
TabIndex = 5
Top = 180
Width = 2415
End
Begin VB.Label Label1
Caption = "输入发送字符区:"
Height = 195
Left = 60
TabIndex = 4
Top = 180
Width = 1695
End
End
Attribute VB_Name = "COMForm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
' 初始化程序:主要完成对串口的设置,包括选择串口、设置波特率、设置数据格式、打开串口等。
' 注意:在程序开始之前,必须清空发送和接收缓冲区,以免出错。
Private Sub Form_Load()
MSComm1.Setting = "9600,n,8,1," ' 设置波特率和发送字符格式
= 1 ' 设置通讯串口
MSComm1.InputLen = 0 ' 设置或返回一次从接收缓冲区中读取字节数,0表示一次读取所有数据
MSComm1.InBufferSize = 512 ' 设置接收缓冲区512Byte
MSComm1.InBufferCount = 0
MSComm1.OutBufferSize = 512 ' 设置发送缓冲区512Byte
MSComm1.OutBufferCount = 0
MSComm1.RThreshold = 1 ' 每个字符到接收缓冲区都触发接收事件
MSComm1.SThreshold = 1
MSComm1.PortOpen = True ' 打开串口
End Sub
'发送数据
'PC机向单片机发送一个"S",表示通信开始,然后紧接着又发送9个字符,
'其中最后一个字符是前面9个字符(包括"S")的校验和。
'单片机正确接收到10个字符后,把10个字符重新又送回来。
Private Sub Cmdsend_C1ick()
Varbuffet = "S"
MSComm1.Ouput = varbuffe
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Outputsignal = Str(Textsend.Text) '向单片机发送其它数据
temp(1) = CByte(Outputsignal)
varbuffer = temp
MSComm1.Output = varbuffer
Timer1.Enabled = False
End Sub
' 接收单片机发送的数据,并显示
Private Sub MSComm1_OnComm()
Select Case ' 设置oncomm事件,读取片机内存的值
Case comEvReceive
Inputsignal = MSComm1.Input
TextReceive.Text = Asc(Inputsignal) ' 单片机内存的值用TextReceive显示出
Case Else
End Select
End Sub
'关闭串口,关闭程序
Private Sub Cmdquit_Click()
MSComm1.PortOpen = False
Unload Me
End Sub