กระทู้เก่าบอร์ด อ.Yeadram
2,442 4
URL.หัวข้อ /
URL
MS-Access กับ Port RS-232,USB
เรียน ท่านสมาชิกทุกท่าน
ตอนนี้ผมกำลังหาตัวอย่างโปรแกรมที่ใช้งานได้จริงของโปรแกรม MS-Access ที่ติดต่อผ่าน Port RS-232 หรือ USB อยู่ครับ
ไม่ทราบว่า สมาชิกท่านใดมีอยู่บ้างอยากจะขอไฟล์ศึกษาหน่อยครับ
ตอนนี้ผมกำลังหาตัวอย่างโปรแกรมที่ใช้งานได้จริงของโปรแกรม MS-Access ที่ติดต่อผ่าน Port RS-232 หรือ USB อยู่ครับ
ไม่ทราบว่า สมาชิกท่านใดมีอยู่บ้างอยากจะขอไฟล์ศึกษาหน่อยครับ
4 Reply in this Topic. Dispaly 1 pages and you are on page number 1
2 @R00514
Private Sub Form_Load()
' chose correct settings for your device
Settings = "9600,n,8,1"
MSComm1.Settings = Settings
MSComm1.Commport = 1
With MSComm1
' receive chr by chr
.InputLen = 1
.RThreshold = 0
.SThreshold = 0
.InBufferSize = 10240 '10kb
.InputMode = comInputModeText
.Handshaking = 0 'None
End With
End Sub
Private Sub Receive()
FileName = App.Path & "\RS232.dat"
Open FileName For Output As #1
Do
DoEvents
RxTxt = MSComm1.Input
' start capture if you get some input
' you may also wait for some other specific character
Loop Until RxTxt > vbNullString
inbuff = vbNullString
Do
DoEvents
RxTxt = MSComm1.Input
' data is supposed to be separated by Chr(10)
' chose another separationmark if neccesary
If RxTxt = Chr(10) And Len(inbuff) > 0 Then
If Left(inbuff, 1) = Chr(10) Then inbuff = Right(inbuff, Len(inbuff) - 1)
Print #1, inbuff
inbuff = vbNullString
Else
If Len(RxTxt) > 0 Then
inbuff = inbuff + RxTxt
End If
End If
' data is supposed to end with Chr(3)
' chose another endmark if neccesary
Loop Until RxTxt = Chr(3)
Close
End Sub
' chose correct settings for your device
Settings = "9600,n,8,1"
MSComm1.Settings = Settings
MSComm1.Commport = 1
With MSComm1
' receive chr by chr
.InputLen = 1
.RThreshold = 0
.SThreshold = 0
.InBufferSize = 10240 '10kb
.InputMode = comInputModeText
.Handshaking = 0 'None
End With
End Sub
Private Sub Receive()
FileName = App.Path & "\RS232.dat"
Open FileName For Output As #1
Do
DoEvents
RxTxt = MSComm1.Input
' start capture if you get some input
' you may also wait for some other specific character
Loop Until RxTxt > vbNullString
inbuff = vbNullString
Do
DoEvents
RxTxt = MSComm1.Input
' data is supposed to be separated by Chr(10)
' chose another separationmark if neccesary
If RxTxt = Chr(10) And Len(inbuff) > 0 Then
If Left(inbuff, 1) = Chr(10) Then inbuff = Right(inbuff, Len(inbuff) - 1)
Print #1, inbuff
inbuff = vbNullString
Else
If Len(RxTxt) > 0 Then
inbuff = inbuff + RxTxt
End If
End If
' data is supposed to end with Chr(3)
' chose another endmark if neccesary
Loop Until RxTxt = Chr(3)
Close
End Sub
3 @R00519
มีตัวเต็มให้ได้ลองหรือเปล่าครับ
4 @R11972
Time: 0.2438s
' chose correct settings for your device
Settings = "9600,n,8,1"
MSComm1.Settings = Settings
MSComm1.Commport = 1
With MSComm1
' receive chr by chr
.InputLen = 1
.RThreshold = 0
.SThreshold = 0
.InBufferSize = 10240 '10kb
.InputMode = comInputModeText
.Handshaking = 0 'None
End With
End Sub
Private Sub Receive()
FileName = App.Path & "\RS232.dat"
Open FileName For Output As #1
Do
DoEvents
RxTxt = MSComm1.Input
' start capture if you get some input
' you may also wait for some other specific character
Loop Until RxTxt > vbNullString
inbuff = vbNullString
Do
DoEvents
RxTxt = MSComm1.Input
' data is supposed to be separated by Chr(10)
' chose another separationmark if neccesary
If RxTxt = Chr(10) And Len(inbuff) > 0 Then
If Left(inbuff, 1) = Chr(10) Then inbuff = Right(inbuff, Len(inbuff) - 1)
Print #1, inbuff
inbuff = vbNullString
Else
If Len(RxTxt) > 0 Then
inbuff = inbuff + RxTxt
End If