编译器:无效的外部过程 [英] compiler: invalid outside procedure
本文介绍了编译器:无效的外部过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
编译器:无效的外部过程
调试时出现错误是什么问题?
compiler: invalid outside procedure
error while debugging what is the problem???
<pre lang="vb">Dim hwdc As Long
Dim startcap As Boolean
'' Fire Rx Event Every Two Bytes
MSComm1.RThreshold = 2
'' When Inputting Data, Input 2 Bytes at a time
MSComm1.InputLen = 2
'' 2400 Baud, No Parity, 8 Data Bits, 1 Stop Bit
MSComm1.Settings = "2400,N,8,1"
'' Make sure DTR line is low to prevent Stamp reset
MSComm1.DTREnable = False
'' Use COM9
MSComm1.CommPort = 9
'' Open the port
MSComm1.PortOpen = True
Private Sub MSComm1_OnComm()
Dim sData As String '' Holds our incoming data
Dim lHighByte As Long '' Holds HighByte value
Dim lLowByte As Long '' Holds LowByte value
Dim lByte As Long '' Holds the Byte result
'' If comEvReceive Event then get data and display
If MSComm1.CommEvent = comEvReceive Then
sData = MSComm1.Input '' Get data
lHighByte = Asc(Mid$(sData, 1, 1)) '' get 1st byte
lLowByte = Asc(Mid$(sData, 2, 1)) '' Get 2nd byte
lByte = JoinHighLow(lHighByte, lLowByte)
Label1.Caption = CStr(lByte)
DrawScale lByte
End If
End Sub
Private Function JoinHighLow(lHigh As Long, lLow As Long) As Long
JoinHighLow = (lHigh * &H100) Or lLow
End Function
Private Sub DrawScale(lVal As Long)
Picture1.Cls
Picture1.Line (0, 0)-(lVal, Picture1.ScaleHeight), vb3DShadow, BF
End Sub
Private Sub Command11_click()
Dim PinNumber As Variant
PinNumber = Text2.DataField
MSComm1.Output = Chr$(255) & Chr$(PinNumber)
End Sub
Private Sub Command2_click()
MSComm1.Output = 3
End Sub
Private Sub Command3_Click()
MSComm1.Output = 4
End Sub
Private Sub Command1_click()
MSComm1.Output = 1
End Sub
Private Sub Command4_Click()
MSComm1.Output = 2
End Sub
Private Sub Command5_Click()
MSComm1.Output = 9
End Sub
Private Sub Command6_Click()
MSComm1.Output = 6
End Sub
Private Sub Command7_Click()
MSComm1.Output = 7
End Sub
Private Sub Command8_Click()
MSComm1.Output = 8
End Sub
Private Sub Command9_Click()
MSComm1.Output = 5
End Sub
Private Sub Form_Load()
'' Default to text2 being selected
Text2.DataField = 0
'' Fire Rx Event Every Two Bytes
MSComm1.RThreshold = 2
'' When Inputting Data, Input 2 Bytes at a time
MSComm1.InputLen = 2
'' 2400 Baud, No Parity, 8 Data Bits, 1 Stop Bit
MSComm1.Settings = "2400,N,8,1"
'' Make sure DTR line is low to prevent Stamp reset
MSComm1.DTREnable = False
'' Use COM17
MSComm1.CommPort = 17
'' Open the port
MSComm1.PortOpen = True
End Sub
Private Sub cmdCapture_Click()
Dim temp As Long
hwdc = capCreateCaptureWindow("NeV0 Vision System", ws_child Or ws_visible, 0, 0, 320, 240, Picture1.hWnd, 0)
If (hwdc <> 0) Then
temp = SendMessage(hwdc, wm_cap_driver_connect, 0, 0)
temp = SendMessage(hwdc, wm_cap_set_preview, 1, 0)
temp = SendMessage(hwdc, WM_CAP_SET_PREVIEWRATE, 30, 0)
startcap = True
Else
MsgBox ("No Webcam found")
End If
End Sub
Private Sub cmdClose_Click()
Dim temp As Long
If startcap = True Then
temp = SendMessage(hwdc, WM_CAP_DRIVER_DISCONNECT, 0&, 0&)
startcap = False
End If
End Sub
Private Sub cmdVideoFormat_Click()
Dim temp As Long
If startcap = True Then
temp = SendMessage(hwdc, WM_CAP_DLG_VIDEOFORMAT, 0&, 0&)
End If
End Sub
推荐答案
(sData,1,1))''得到第一个字节 lLowByte = Asc(Mid
(sData, 1, 1)) '' get 1st byte lLowByte = Asc(Mid
(sData,2,1))''获取第二个字节 lByte = JoinHighLow(lHighByte,lLowByte) Label1.Caption = CStr(lByte) DrawScale lByte 万一 结束子 私有函数JoinHighLow(lHigh只要Long,lLow只要Long) JoinHighLow =(lHigh *& H100)或lLow 结束功能 私人子画比例(lVal as long) 图片1.Cls Picture1.Line(0,0)-(lVal,Picture1.ScaleHeight),vb3DShadow,BF 结束子 私人子Command11_click() 暗淡PinNumber作为变体 PinNumber = Text2.DataField MSComm1.Output = Chr
(sData, 2, 1)) '' Get 2nd byte lByte = JoinHighLow(lHighByte, lLowByte) Label1.Caption = CStr(lByte) DrawScale lByte End If End Sub Private Function JoinHighLow(lHigh As Long, lLow As Long) As Long JoinHighLow = (lHigh * &H100) Or lLow End Function Private Sub DrawScale(lVal As Long) Picture1.Cls Picture1.Line (0, 0)-(lVal, Picture1.ScaleHeight), vb3DShadow, BF End Sub Private Sub Command11_click() Dim PinNumber As Variant PinNumber = Text2.DataField MSComm1.Output = Chr
(255)& Chr
(255) & Chr
这篇关于编译器:无效的外部过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文