我对我的编码进行了一些更改并对其进行了测试。它仍然无法正常工作,因此我希望在这里得到一些指导。
Imports System
Imports System.Data
Imports System.Configuration
Imports System.Collections
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports System.IO.Ports
Partial Class Main
Inherits System.Web.UI.Page
Protected Sub form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles form1.Load
Dim Serialport7 As New IO.Ports.SerialPort
With Serialport7
.PortName = "COM7"
.BaudRate = 9600
.Parity = Parity.None
.DataBits = 8
.StopBits = StopBits.One
End With
Try
Serialport7.Open()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
Dim ReceivedData As String
ReceivedData = Serialport7.ReadLine()
If ReceivedData.Substring(0, 1) = "T" Then
TextBox1.Text = ReceivedData.Remove(0, 1)
ElseIf ReceivedData.Substring(0, 1) = "H" Then
TextBox2.Text = ReceivedData.Remove(0, 1)
End If
TextBox3.Text = System.DateTime.Now
Serialport7.Close()
End Sub
End Class
我遇到的错误:
TextBox2 不显示读数,只有 TextBox1 显示读数。
Web 表单没有刷新,因此我的读数没有更新。有什么办法可以自动更新 Web 表单?
感谢所有指导。谢谢。