使用数据接收事件 [英] using data received events

查看:101
本文介绍了使用数据接收事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨论坛

我不知道如何使用我给出的代码中的数据接收事件..请你帮我。我不知道在哪里放数据接收事件。

I am not sure how to use data received events from this code I given.. Can you help me please.I dont know where to put the data received events.

Imports System.IO
Imports System.IO.Ports
Imports System.Threading
Imports System.Data
Imports System.Text


Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
        SerialPort1.Close()
        SerialPort1.PortName = "com4" 'change com port to match your Arduino port
        SerialPort1.BaudRate = 9600
        SerialPort1.DataBits = 8
        SerialPort1.Parity = Parity.None
        SerialPort1.StopBits = StopBits.One
        SerialPort1.Handshake = Handshake.None
        SerialPort1.Encoding = System.Text.Encoding.Default 'very important!


    End Sub
 

    Private Sub Start_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Start.Click

        Dim SP As String
        Dim FB As Integer
        Dim A As Integer

        SP = TextBox1.Text
        FB = CInt(Label2.Text)
        A = SP - FB
        Label3.Text = A

        SerialPort1.Open()
        SerialPort1.Write(A)

    End Sub



    Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As EventArgs)
        Dim s As String
        Try
            s = SerialPort1.ReadExisting()
            Label2.Text = s
        Catch ex As Exception

        End Try
    End Sub






End Class




推荐答案

由于代码是vb.net,明显的起点是我一个视觉工作室解决方案。如果您尝试将其与visio解决方案一起使用,那么它将是带有绘图控件或附加应用程序的Windows应用程序。

since the code is vb.net the obvious starting point is in a visual studio solution. If you're attempting to use it with a visio solution then it will either be a windows application with a drawing control or an add-in application.

al


这篇关于使用数据接收事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆