Home > Software engineering >  Which good intention person to help me to change my under vb program
Which good intention person to help me to change my under vb program

Time:10-05

I am a senior student, the thesis topic is "superior tact to instrument based on vb program design", using vb communication MSComm control and programming methods of upper machine (PC) the design of communication software, realize the upper machine and lower machine (single chip microcomputer system) between the data transmission and real-time data acquisition, the teacher means that the voltage, current, power through a picture display interface, then the value in excel, I only made a voltage, running a few problems, I was under the vb6.0 by use enterprise edition, but controls cannot find PortOpen, inbuffercount, input, output, want to add "Microsoft excel Object Library" can't find in the engineering reference, found the Kingsoft excel Object Library, results show that the "load the DLL error", it is after the operation without coordinates, bother everybody to help me take a look at how to modify the

Dim myexcel As Excel. The Application the Application object variables'
Dim mybook As Excel. The Workbook 'work thin object variables
Dim mysheet As Excel. The Worksheet 'Worksheet object variables
Dim n As Integer 'definition in a spreadsheet rows of existing content variable

'" start gathering "code:
Private Sub Command1_Click ()
Timer1. Enabled=True
Timer2. Enabled=True
Call the draw
The Set myexcel=Excel. Application 'start Excel Application software
The Set mybook=myexcel. Workbooks. Open (" e:/meter. XLS ") 'Open e thin plate work file "
Set mysheet=mybook. Worksheets (1) 'mysheet work points to 1 piece of thin sheet
Myexcel. Visible=True 'show Excel application environment visual ()
N=mysheet. UsedRange. Rows. The Count 'access to a spreadsheet Rows of existing content
End Sub

'" stop monitoring code
"Private Sub Command2_Click ()
Timer1. Enabled=False 'is not allowed to Timer1 timing
Mybook. Save 'to Save work thin
Myexcel. Quit 'close Excel application software
End Sub


'note: before the program starts, must empty the sending and receiving buffer, in order to avoid error,
Private Sub Form_Load ()
MSComm1. Settings="9600, n, 8, 1" 'set the baud rate and send character format
MSComm1.Com mPort=1 'setting communication serial port
MSComm1. InputLen=0 'sets or returns a read number of bytes, from the receive buffer 0 indicates a read all data
MSComm1. InBufferSize=512 'sets the receive buffer 512 byte
MSComm1. InBufferCount=0
MSComm1. OutBufferSize=512 'sets the send buffer 512 byte
MSComm1. OutBufferCount=0
MSComm1. RThreshold=6 'every character to the receive buffer receive events triggered
MSComm1. SThreshold=1
End Sub


'receiving MCU send data, and displays a
Private Sub MSComm1_OnComm ()
Dim inth () As Byte 'store input Byte type sampling data
Dim th (5) As Single 'store type Byte into a Single data
Dim vol As a Single 'voltage value
If MSComm1.Com mEvent=comEvReceive Then
Inth=MSComm1. Input type 'Input Byte data into inth
For I=0 To 5
Th (I)=inth (I) 'the Byte type into a Single type deposit in t h
Next I
If (inth (0) Xor inth Xor inth (1) (2) the Xor inth Xor inth (3) (4))=inth (5) Then
'xor check correctly:
Vol=th (2) * 256 + th calculations (1) voltage sampling values (binary to decimal)
Vol vol/=50 * 1024 'calculation of voltage measurements
Vol Format of=$(vol, "0.0")

Text2. Text=vol & amp; "V" 'text box shows no. 1 table measured values
N=n + 1 'existing content in the spreadsheet rows + 1 (that is, pointing to the first empty row)
Mysheet. Cells (n, 1). The Value=https://bbs.csdn.net/topics/Time 'current time deposited in the cell
Mysheet. Cells (n, 2). The Value=https://bbs.csdn.net/topics/vol 'voltage values in table 1 n row 2 column cell

End the If

End the If
Mybook. Save 'to Save work thin 1 table holds 1 times (read)
End the If
Select Case MSComm1.Com mEvent 'set the oncomm event, machine memory reading
Case comEvReceive
Inputsignal=MSComm1. Input
Text2. Text microcontroller memory=Asc (Inputsignal) 'value in Text2 show
In Case the Else
End the Select
End Sub

'map coordinates are function
Private Sub Picture1_draw map coordinate system () '
Dim X As Integer
Dim Y As Integer
Picture1. Scale (100, 70) - (1600-10) 'define coordinates to draw coordinate system
Picture1. ForeColor=RGB (200, 5, 200)
Picture1. DrawWidth=1
Picture1. Line (0, 0) - (0, 65
Picture1. Line (0, 0) - (1550, 0) 'draw coordinate point voltage (1 to 10 v)
Picture1. ForeColor=RGB (0, 0, 255)
Picture1. DrawWidth=4
For Y=0 To 60 Step 10
Picture1. PSet (0, Y)
Next Y 'draw coordinate point voltage (1 to 1 v)
Picture1. ForeColor=RGB (0, 0, 255)
Picture1. DrawWidth=2
For Y=1 To 59
Picture1. PSet (0, Y)
Next X 'time coordinate points (1 to 1 hour)
For X=0 To 1440 Step 60
Picture1. PSet (X, 0)
Next X 'time coordinate points (1 to 6 hours)
Picture1. ForeColor=RGB (0, 0, 255)
Picture1. DrawWidth=4
Picture1. PSet (720, 0)
Picture1. PSet (360, 0)
Picture1. PSet (1080, 0)
Picture1. PSet (1440, 0)
End Sub


'extraction and single chip microcomputer temperature data, and realize dynamic drawing
Private Sub Time2_Timer ()
'used to extract serial real-time data and real-time drawing, measuring voltage can extract data per minute to
Dim t As Single
T=Val (Text2. Text) 'real-time voltage change curve drawing
Real-time voltage change curve drawing '
Picture1. ForeColor=RGB (0, 0, 255)
Picture1. DrawWidth=3
X=X + 1
Picture1. PSet (X, t)
If X & gt; Then 1440
Picture1. Cls
X=0 '
refresh coordinate systemCall the draw
End Sub




Now run out, no coordinate display,

CodePudding user response:

Microsoft Excel Object Library need to install Microsoft office Excel
No equipment can't test...

CodePudding user response:

I installed but is not the trouble you help me to look at the code what's the problem

CodePudding user response:

1, excel engineering Library is generally 11.0 Microsoft excel Object Library 12.0 Object or Microsoft excel form such as the Library;
2, Set myexcel=Excel. Application 'start Excel Application software
The sentence should be amended as: Set myexcel=new Excel. The Application of 'start Excel Application software
3, multi-purpose with... Will end with the structure has many advantages... Refer to the following code (not debugging, debugging and see which error)
 Option Explicit 
Dim MyExcel As Excel. The Application the Application object variables'
Dim MyBook As Excel. The Workbook 'work thin object variables
Dim MySheet As Excel. The Worksheet 'Worksheet object variables
Dim n As Integer 'definition in a spreadsheet rows of existing content variable
'" start gathering "code:
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related