Home > Software engineering >  VB 28 stack overflow error in real time
VB 28 stack overflow error in real time

Time:10-15

Under the code,
Do Until MSComm1. InBufferCount=24 'query, waits to receive 24 characters
DoEvents
Loop
This sentence no time there will be no overflow, but collects the data between each group of a group of 0, when having this error message will appear, this is why,


 Private theGmj1 As myGmj. GMJ 
Private theGmj2 As mytu. Tu
Dim num As the number of Integer 'data
Dim Data3 (1000), Data4 (1000), Data5 (1000), Data6 (1000) As Single
Dim data1 (1000) As Single 'data sampling voltage numerical form
Dim data2 (1000) As Single
Dim filedata3 (1000), filedata4 (1000), filedata5 (1000), filedata6 (1000) As the String
Dim filedata1 (1000) As the String
Dim filedata2 (1000) As the String
Dim As Integer I
Dim UX1 As Double
Dim UX2 As Double
Dim UY1 As Double
Dim UY2 As Double
Dim a1 As the Variant
Dim b2 As the Variant

Dim Buffer (3) As String 'data array

Dim dbconn As New ADODB. Connection
Dim the rs As New ADODB. You


Private Sub Form_Load initialization () '

If dbconn. State Then dbconn. Close
Dbconn. Open the Provider="Microsoft. Jet. The OLEDB. 4.0; The Data Source="+ App. Path +" \ Data. MDB. Persist Security Info=False "

The Set theGmj1=New myGmj. GMJ
The Set theGmj2=New mytu. Tu
MSComm1. Settings="9600, n, 8, 1" 'set the communication port parameter
MSComm1.Com mPort=4 'use COM4
MSComm1. PortOpen=True 'open communication port
MSComm1. InputLen=6 'set the Input a number of bytes read from the receive buffer is 6
MSComm1. An InputMode=0 'data are read by text
MSComm1. OutBufferCount=0 'removal send buffer
MSComm1. SThreshold=6 'setting the Output a number of bytes read from the send buffer is 6
Cmdget2. Enabled=True
Cmdstop3. Enabled=True
Cmdquit. Enabled=True
Call tabinit
End Sub

Private Sub MSComm1_OnComm () 'serial port communication, to collect

Do Until MSComm1. InBufferCount=24 'query, waits to receive 24 characters
DoEvents
Loop

Select Case mEvent 'serial events
MSComm1.ComCase comEvReceive 'receives the data

For I=0 To 3
Buffer (I)=MSComm1. Input
Select a Case I
Case 0
UX1=Val (Buffer (0))
Case 1
UX2=Val (Buffer (1))
Case 2
UY1=Val (Buffer (2))
Case 3
UY2=Val (Buffer (3))
End the Select
Next I

Data3 (num)=UX1
Filedata3 (num)=Format $(Data3 (num), "0.00")
Text1. Text=filedata3 (num)
Data4 (num)=UY1
Filedata4 (num)=Format $(Data4 (num), "0.00")
Text2. Text=filedata4 (num)
Data5 (num)=UY2
Filedata5 (num)=Format $(Data5 (num), "0.00")
Text3. Text=filedata5 (num)
Data6 (num)=UX2
Filedata6 (num)=Format $(Data6 (num), "0.00")
Text4. Text=filedata6 (num)
Call theGmj1. Gmj_gmj (2, a1, b2, UX1 UX2, UY1, UY2) 'Call matlab
Call theGmj2. X3 (1 g, a1, b2)
Data1=a1 (num)
Filedata1 (num)=Format $(data1 (num), "0.00")
Tu1. Text=filedata1 (num)
Data2=b2 (num)
Filedata2 (num)=Format $(data2 (num), "0.00")
Tu2. Text=filedata2 (num)
MSFlexGrid1. TextMatrix (num, 1)=filedata3 (num)
MSFlexGrid1. TextMatrix (num, 2)=filedata6 (num)
MSFlexGrid1. TextMatrix (num, 3)=filedata5 (num)
MSFlexGrid1. TextMatrix (num, 4)=filedata4 (num)
MSFlexGrid1. TextMatrix (num, 5)=filedata1 (num)
MSFlexGrid1. TextMatrix (num, 6)=filedata2 (num)

Dim rsJin As New ADODB. You
If rsJin. State Then rsJin. Close
RsJin. Open the "select top 1 * from data save," dbconn, adOpenKeyset, adLockPessimistic
RsJin. AddNew
RsJin. Fields (" Date ")=Date
RsJin. Fields (" Time ")=Time
RsJin. Fields (" sensor (1)=filedata3 (num)
RsJin. Fields (4 "sensor")=filedata6 (num)
RsJin. Fields (2 "sensor")=filedata5 (num)
RsJin. Fields (3 "sensor")=filedata4 (num)
RsJin. Fields (" alpha ")=filedata1 (num)
RsJin. Fields (" beta ")=filedata2 (num)
RsJin. Update
Dim rs1 As New ADODB. You
If rs1. State Then rs1. Close
Rs1. Open the "select top 30 * from data preservation order by desc" time, dbconn, adOpenKeyset, adLockPessimistic

Num=num + 1
If num & gt; 199 Then Call renew
Call the draw
Call tabinit
MSComm1. InBufferCount=0
End the Select

End Sub

Private Sub Cmdget2_Click continuous acquisition
() 'MSComm1. RThreshold=1 'is set to receive a byte produced Oncomm events
Timer1. Enabled=True 'clock effective
Serial communication Call MSComm1_OnComm '
End Sub

Private Sub the draw ()
Picture1. Cls
Picture1. DrawWidth=1
Picture1. BackColor=QBColor (15)
Picture1. Scale (0, 3.14) - (200, 3.14)
Picture2. Cls
Picture2. DrawWidth=1
Picture2. BackColor=QBColor (15)
Picture2. Scale (0, 3.14) - (200, 3.14)

For I=1 To 1
num -X1=(I - 1) : Y1=data1 (I - 1)
X2=I: Y2=data1 (I)
Picture1. Line (X1, Y1) - (X2, Y2), QBColor (0)

X1=(I - 1) : Y1=data2 (I - 1)
X2=I: Y2=data2 (I)
Picture2. Line (X1, Y1) - (X2, Y2), QBColor (0)

Next I

End Sub

Private Sub Command1_Click ()
Dbconn. Execute "delete from data save
"End Sub

nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related