注册 登录
编程论坛 VB6论坛

在VB中怎么清除上次的直方图?

wxl900306 发布于 2013-03-05 21:08, 524 次点击
我用VB做一个表决系统,现在是可以接收到数据,但发送序列号时无法清除上次投票结果的内容,帮忙看看!!!谢了
只有本站会员才能查看附件,请 登录
只有本站会员才能查看附件,请 登录
程序代码:
Private Sub MSComm1_OnComm()
    Dim BytReceived() As Byte
    Dim strBuff As Variant
   
    Select Case Case 2
        MSComm1.InputLen = 0
        strBuff = MSComm1.Input
        BytReceived() = strBuff
        Dim i As Long
        For i = 0 To UBound(BytReceived)
           Debug.Print BytReceived(i)
        Next
        If i <= 2 Then
        Text2 = BytReceived(0)
        BytReceived(0) = 0
        Else
        tongyi = BytReceived(0)
        BytReceived(0) = 0
        fandui = BytReceived(2)
        BytReceived(2) = 0
        qiquan = BytReceived(4)
        BytReceived(4) = 0
        End If
    End Select
'绘制直方图
'
CurrentX = 2 + 2: CurrentY = Text1.Text                                             '找到绘制“赞同”直方图的起始位置
Line (6240 + 940, 4560 - 30)-(6240 + 1880, 4560 - tongyi * 360), vbGreen, BF     '绘制“赞同”直方图
CurrentX = 6240 + 1410: CurrentY = 4560 - tongyi * 360 - 200: Print tongyi

Line (6240 + 2820, 4560 - 30)-(6240 + 3760, 4560 - fandui * 360), vbYellow, BF        '绘制“反对”直方图
CurrentX = 6240 + 3290: CurrentY = 4560 - fandui * 360 - 200: Print fandui

Line (6240 + 4700, 4560 - 30)-(6240 + 5640, 4560 - qiquan * 360), vbRed, BF           '绘制“弃权”直方图
CurrentX = 6240 + 5170: CurrentY = 4560 - qiquan * 360 - 200: Print qiquan

End Sub
4 回复
#2
lowxiong2013-03-05 22:15
Private Sub MSComm1_OnComm()
    Dim BytReceived() As Byte
    Dim strBuff As Variant
   
    Select Case
        Case 2
        MSComm1.InputLen = 0
        strBuff = MSComm1.Input
        BytReceived() = strBuff
        Dim i As Long
        For i = 0 To UBound(BytReceived)
           Debug.Print BytReceived(i)
        Next
        If i <= 2 Then
        Text2 = BytReceived(0)
        BytReceived(0) = 0
        Else
        tongyi = BytReceived(0)
        BytReceived(0) = 0
        fandui = BytReceived(2)
        BytReceived(2) = 0
        qiquan = BytReceived(4)
        BytReceived(4) = 0
        End If
    End Select
'绘制直方图
'CurrentX = 2 + 2: CurrentY = Text1.Text                                             '找到绘制“赞同”直方图的起始位置
Line (6240 + 940, 4560 - 30)-(6240 + 1880, 4560 - 10 * 360), me.backcolor, BF    '清除上次同意的直方图
Line (6240 + 940, 4560 - 30)-(6240 + 1880, 4560 - tongyi * 360), vbGreen, BF     '绘制“赞同”直方图
CurrentX = 6240 + 1410: CurrentY = 4560 - tongyi * 360 - 200: Print tongyi
Line (6240 + 2820, 4560 - 30)-(6240 + 3760, 4560 - 10 * 360), me.backcolor, BF            '清除上次反对的直方图        
Line (6240 + 2820, 4560 - 30)-(6240 + 3760, 4560 - fandui * 360), vbYellow, BF        '绘制“反对”直方图
CurrentX = 6240 + 3290: CurrentY = 4560 - fandui * 360 - 200: Print fandui
Line (6240 + 4700, 4560 - 30)-(6240 + 5640, 4560 - qiquan * 360), me.backcolor, BF    '清除上次弃权的直方图        
Line (6240 + 4700, 4560 - 30)-(6240 + 5640, 4560 - qiquan * 360), vbRed, BF           '绘制“弃权”直方图
CurrentX = 6240 + 5170: CurrentY = 4560 - qiquan * 360 - 200: Print qiquan

End Sub

#3
wxl9003062013-03-06 09:15
太感谢了,早上试了,成功了,谢了
#4
wxl9003062013-03-06 09:21
回复 2楼 lowxiong
还有一个问题,就是我们实验用的开发板上时,同意反对弃权这三个值都可以正常的采集到并显示出来,但是我改成了自己的板子,同意反对都可以成功的采集并显示,但弃权怎么都显示不出来,我想硬件这个问题可以排除的,因为我弃权=总人数-同意-反对,所以即使没有按下任何同意反对弃权按键,他返回上位机的应该都是弃权,但就是无法显示,这可能是上位机的问题吗?
同样在开发板上上位机程序没问题,但到我自己的板子上上位机仍然没有改变,所以我不知道那里有问题了。可以帮忙分析一下么
#5
wxl9003062013-03-06 09:23
回复 2楼 lowxiong
因为有关vb方面的知识我只看了一个星期,没有过多的研究,我怀疑是不是这里的问题呢,      
        If i <= 2 Then
        Text2 = BytReceived(0)
        BytReceived(0) = 0
        Else
        tongyi = BytReceived(0)
        BytReceived(0) = 0
        fandui = BytReceived(2)
        BytReceived(2) = 0
        qiquan = BytReceived(4)
        BytReceived(4) = 0
        End If
1