VB编写串口数据采集程序坐标图显示

VB编写串口数据采集程序坐标图显示
如何用VB实现该程序,图片在我的百度空间相册里!(其中的输入曲线,基本参数两个框不需要,坐标图下的只保留交流放大倍数)
通过串口调试助手3.3 传送数据,一共传送四组,分四次传送!
比如这样的四组 这些数据是通过51单片机采集的!
IB=0时 uce 0,2,4,6,8
IC 0,0,0,0,0

IB=10时 uce 0,2,4,6,8
IC 3,3,3,3,3

IB=20时 uce 0,2,4,6,8
IC 6,6,6,6,6

IB=30时 uce 0,2,4,6,8
IC 8.5,8.5,8.5,8.5

这些都是模拟数据,还没做实验采集数据,数据形式应该差不多.
实现计算并显示出任以两点的交流放大倍数β,即把鼠标点在曲线图上,坐标图下方显示交流放大倍数(做个除法),β=IC/IB
在每个曲线的右边都要显示IB的值,就向图片里的那样.横坐标与纵坐标和图片里的一样.

我对VB不通才刚刚学习,希望能高手能给出程序的完整源代码和必要的注释啊,我好研究啊!
请把程序的完整源代码发往[email protected],万分感谢了!

我可能描述的不够详细,欢迎通过站内信息联系啊!

图片地址:http://hi.baidu.com/haobubu1988/album/item/4ffc6bd642d07f3c06088b58.html

Option Explicit
Dim sj_x(50) As Single
Dim sj_y(500) As Single
Dim sj_x1(500) As Single
Dim sj_y1(500) As Single
Dim i As Integer
Dim BytReceived() As Byte
Dim strData As String
Dim lenInput As Integer
Dim x As Integer
Dim y As Integer
Dim fnt As Integer
Dim txt As String
Dim dd
Dim sum As Integer
Private Sub Command1_Click()
Picture1.Cls
For i = 0 To sum
sj_x1(i) = sj_x(i) * 10 + 10
sj_y1(i) = sj_y(i) * 10 + 10
Next
Dim OldFontSize
AutoRedraw = -1 ' 打开AutoRedraw。
OldFontSize = FontSize ' 保持旧的字体大小。
Picture1.Scale (0, 150)-(120, 0) ' 设定自定义座标系统。
Picture1.DrawWidth = 2
Picture1.Line (10, 5)-(10, 130), RGB(0, 0, 255), BF ' 蓝色条。
Picture1.Line (5, 10)-(110, 10), RGB(0, 0, 255), BF ' 蓝色条。
Picture1.DrawWidth = 5
For i = 0 To sum
Picture1.PSet (sj_x1(i), sj_y1(i)), RGB(250, 0, 255)
Next
Picture1.DrawWidth = 2
For i = 10 To 130 Step 10
Picture1.Line (8, i)-(10, i) ' 每隔 10 个单位划尺寸标记。
Next i
For i = 10 To 110 Step 10
Picture1.Line (i, 10)-(i, 12) ' 每隔 10 个单位划尺寸标记。
Next i
Command6_Click
End Sub

Private Sub Command3_Click()
Picture1.Cls
Dim OldFontSize
AutoRedraw = -1 ' 打开AutoRedraw。
OldFontSize = FontSize ' 保持旧的字体大小。
Picture1.Scale (0, 150)-(120, 0) ' 设定自定义座标系统。
Picture1.DrawWidth = 2
Picture1.Line (10, 5)-(10, 130), RGB(0, 0, 255), BF ' 蓝色条。
Picture1.Line (5, 10)-(110, 10), RGB(0, 0, 255), BF ' 蓝色条。
Picture1.DrawWidth = 5
For i = 0 To 39
Picture1.PSet (sj_x(i), sj_y(i)), RGB(250, 0, 255)
Next
Picture1.DrawWidth = 2
For i = 10 To 130 Step 10
Picture1.Line (8, i)-(10, i) ' 每隔 10 个单位划尺寸标记。
Next i
For i = 10 To 110 Step 10
Picture1.Line (i, 10)-(i, 12) ' 每隔 10 个单位划尺寸标记。
Next i
Command6_Click
End Sub

Private Sub Command4_Click()
If MSComm1.PortOpen = False Then
MSComm1.PortOpen = True
End If
End Sub

Private Sub Command5_Click()
Picture1.Cls
End Sub

Private Sub Command6_Click()
fnt = 12
x = 5
y = 140
txt = "IC mA"
dd = prnt(x, y, fnt, txt)
x = 2
For i = 1 To 13
y = 10 * i + 3
txt = i
dd = prnt(x, y, fnt, txt)
Next
x = 0
y = 6
For i = 0 To 10
x = i * 10 + 8
txt = i
dd = prnt(x, y, fnt, txt)
Next
x = 110
y = 16
txt = "VC V"
dd = prnt(x, y, fnt, txt)
End Sub

Private Sub Form_Load()
sj_x(0) = 0: sj_y(0) = 0
sj_x(1) = 0.25: sj_y(1) = 5
sj_x(2) = 0.5: sj_y(2) = 8
sj_x(3) = 0.75: sj_y(3) = 10.1
sj_x(4) = 1: sj_y(4) = 10.2
sj_x(5) = 1.25: sj_y(5) = 10.25
sj_x(6) = 1.5: sj_y(6) = 10.3
sj_x(7) = 1.75: sj_y(7) = 10.35
sj_x(8) = 2: sj_y(8) = 10.4
sj_x(9) = 2.25: sj_y(9) = 10.455
sj_x(10) = 2.55: sj_y(10) = 10.5
sj_x(11) = 2.75: sj_y(11) = 10.511
sj_x(12) = 3: sj_y(12) = 10.512
sj_x(13) = 3.25: sj_y(13) = 10.513
sj_x(14) = 3.5: sj_y(14) = 10.5
sj_x(15) = 3.75: sj_y(15) = 10.517
sj_x(16) = 4: sj_y(16) = 10.52
sj_x(17) = 4.25: sj_y(17) = 10.518
sj_x(18) = 4.5: sj_y(18) = 10.518
sj_x(19) = 4.75: sj_y(19) = 10.52
sj_x(20) = 5: sj_y(20) = 10.5235
sj_x(21) = 5.25: sj_y(21) = 10.5235
sj_x(22) = 5.5: sj_y(22) = 10.53
sj_x(23) = 5.75: sj_y(23) = 10.51
sj_x(24) = 6: sj_y(24) = 10.52
sj_x(25) = 6.25: sj_y(25) = 10.53
sj_x(26) = 6.5: sj_y(26) = 10.53
sj_x(27) = 6.75: sj_y(27) = 10.535
sj_x(28) = 7: sj_y(28) = 10.54
sj_x(29) = 7.25: sj_y(29) = 10.5455
sj_x(30) = 7.5: sj_y(30) = 10.6
sj_x(31) = 7.75: sj_y(31) = 10.631
sj_x(32) = 8: sj_y(32) = 10.62
sj_x(33) = 8.25: sj_y(33) = 10.633
sj_x(34) = 8.5: sj_y(34) = 10.633
sj_x(35) = 8.75: sj_y(35) = 10.62
sj_x(36) = 9.01: sj_y(36) = 10.65
sj_x(37) = 9.25: sj_y(37) = 10.651
sj_x(38) = 9.5: sj_y(38) = 10.66
sj_x(39) = 9.75: sj_y(39) = 10.66
For i = 0 To 39
sj_x(i) = sj_x(i) * 10 + 10
sj_y(i) = sj_y(i) * 10 + 10
Next
Dim OldFontSize
AutoRedraw = -1 ' 打开AutoRedraw。
OldFontSize = FontSize ' 保持旧的字体大小。
Picture1.Scale (0, 150)-(120, 0) ' 设定自定义座标系统。
Picture1.DrawWidth = 2
Picture1.Line (10, 5)-(10, 130), RGB(0, 0, 255), BF ' 蓝色条。
Picture1.Line (5, 10)-(110, 10), RGB(0, 0, 255), BF ' 蓝色条。
Picture1.DrawWidth = 2
For i = 10 To 130 Step 10
Picture1.Line (8, i)-(10, i) ' 每隔 10 个单位划尺寸标记。
'Picture1.Print (i - 10) \ 10 ' Print scale mark value on left.
Next i
For i = 10 To 110 Step 10
Picture1.Line (i, 10)-(i, 12) ' 每隔 10 个单位划尺寸标记。
'Picture1.Print i ' Print scale mark value on left.
Next i
MSComm1.Settings = "9600,N,8,1"
MSComm1.InputMode = comInputModeBinary
MSComm1.RThreshold = 4
Command6_Click
End Sub

Private Sub MSComm1_OnComm() '接收数据
Dim strBuff As String
Select Case MSComm1.CommEvent
Case 2
MSComm1.InputLen = 0
strBuff = MSComm1.Input
BytReceived() = strBuff
jieshou
'数据处理代码
'If Len(strData) = 8 Then
Text4 = strData
sj_x(sum) = Val(Mid(strData, 1, 4)) / 10
Label1 = sj_x(sum)
sj_y(sum) = Val(Mid(strData, 5, 4)) / 10
Label2 = sj_y(sum)
sum = sum + 1
strData = ""
'End If
End Select
End Sub
Public Function jieshou() '接收数据处理为16进制
Dim i As Integer
For i = 0 To UBound(BytReceived)
If Len(Hex(BytReceived(i))) = 1 Then
strData = strData & "0" & Hex(BytReceived(i))
Else
strData = strData & Hex(BytReceived(i))
End If
Next
End Function

Public Function prnt(x As Variant, y As Variant, fnt As Variant, txt As Variant)
Picture1.CurrentX = x
Picture1.CurrentY = y
Picture1.FontSize = fnt
Picture1.Print txt
End Function
温馨提示:答案为网友推荐,仅供参考