Timer里的又一个函数处理问题
我自己设想的一个两程序通信,因为我不会动态内存分配,于是就设想利用ACCESS作为中介,程序一在ACCESS表里插入数据,而程序二一直扫描表中的数据并显示出来。
可是我的TIMER的INTERVAL设定为100,可是显示的速度确远远没大于100MS,有将近2到3S啊。
这是接近端程序:
这是发送端程序:
可是我的TIMER的INTERVAL设定为100,可是显示的速度确远远没大于100MS,有将近2到3S啊。
这是接近端程序:
Imports System.Data
Imports System.Data.OleDb
Public Class Form1
Dim textWord As String = "text.mdb"
Dim UseWord As String = "C:\test.mdb"
Dim objconnection As OleDbConnection
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
objconnection = New OleDbConnection("Provider = Microsoft.JET.OLEDB.4.0;" & "Data source = " & UseWord & ";")
objconnection.Open()
Timer1.Enabled = True
Timer1.Interval = 100
Try
SheetDisplay(grdResults, objconnection)
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
txtRecive.Text = grdResults.SelectedCells.Item(1).Value
End Sub
Public Sub SheetDisplay(ByVal grdResults As DataGridView, ByVal objconnection As OleDbConnection)
Dim binding As New BindingSource
Dim SQLString As String = "SELECT * FROM Buffer"
Dim objCommand As New OleDbCommand(SQLString, objconnection)
objCommand.CommandType = CommandType.Text
Dim objDataAdapter As New OleDbDataAdapter
Dim objDataTable As New DataTable
objDataAdapter.SelectCommand = objCommand
objDataAdapter.Fill(objDataTable)
binding.DataSource = objDataTable
grdResults.DataSource = binding
grdResults.MultiSelect = False
grdResults.EditMode = DataGridViewEditMode.EditProgrammatically
grdResults.SelectionMode = DataGridViewSelectionMode.FullRowSelect
binding.MoveLast()
End Sub
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Try
SheetDisplay(grdResults, objconnection)
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
txtRecive.Text = grdResults.SelectedCells.Item(1).Value
End Sub
End Class
这是发送端程序:
Imports System.Data
Imports System.Data.OleDb
Public Class Form1
Dim textWord As String = "Test.mdb"
Dim UseWord As String = "C:\Test.mdb"
Dim objconnection As OleDbConnection
Dim SQLString As String
Dim R_ID As String = "ABB"
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
objconnection = New OleDbConnection("Provider = Microsoft.JET.OLEDB.4.0;" & "Data source = " & UseWord & ";")
Try
objconnection.Open()
Catch oledbexceptionErr As OleDbException
MessageBox.Show(oledbexceptionErr.Message, "Access SQL")
Catch InvalidoperationExceptionErr As InvalidOperationException
MessageBox.Show(InvalidoperationExceptionErr.Message, "Access SQL")
End Try
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
SQLString = "INSERT INTO Buffer (R_ID) values('" & TextBox1.Text & "')"
Dim objcommand As OleDbCommand = New OleDbCommand(SQLString, objconnection)
Dim count As Integer = 0
Try
count = objcommand.ExecuteNonQuery()
Catch ex As Exception
MessageBox.Show(ex.ToString())
End Try
End Sub
End Class
...全文
相关推荐
Pomodoro-Timer
番茄定时器 该存储库中的代码是由Angela Yu博士创建的“ 100天的代码-2021年完整的Python Pro训练营”课程开发的。链接至该课程: :
Matlab中Timer的使用
Matlab中Timer的使用: 鉴于Matlab中缺乏多线程机制,使用Timer 无疑是一个很重要的工具,Matlab中Timer 是一个Java 对象。
C#中Timer使用及解决重入问题
本文主要介绍了C#中Timer使用及解决重入问题的相关知识。具有很好的参考价值,下面跟着小编一起来看下吧
VBA中的Timer函数用法
主要介绍了VBA中的Timer函数用法,需要的朋友可以参考下
C#中Forms.Timer、Timers.Timer、Threading.Timer的用法分析
主要介绍了C#中Forms.Timer、Timers.Timer、Threading.Timer的用法分析,以实例形式较为详细的讲述了.NET Framework里面提供的三种Timer具体用法,需要的朋友可以参考下


