Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

write data into text file error!

Status
Not open for further replies.

member_tdh

Member level 5
Joined
Feb 6, 2006
Messages
86
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Activity points
2,187
Hi!

My project's work is: reat data from COM port, then report data into a text file but my result is:
"textfile.txt"

E1234567
E12345678910

I don't know why it error!

Could anybody help me!? Thanks so much!

Private Sub MSComm1_OnComm()
Dim k As Long, i As Long
Dim Buffer As Variant
Dim BytesReceived() As Byte
Dim sRxData As String
Dim sRD As String
Dim FileNum As Byte
Dim FileName As String

FileNum = FreeFile
FileName = "C:\Documents and Settings\khac trung kien\Desktop\DataApr2008.txt"
Open FileName For Append As #FileNum
With MSComm1
If .InBufferCount >= 1 Then
nCount = nCount + .InBufferCount
Label4.Caption = nCount
Label4.AutoSize = True

Select Case .CommEvent
Case comEvReceive
'Buffer = .Input 'Get serial Data
'BytesReceived() = Buffer
sRxData = sRxData & MSComm1.Input
If sRxData = "" Then sRxData = 0
For i = 1 To Len(sRxData)
Text2.Text = Text2.Text & Hex$(Asc(Mid$(sRxData, i, 1)))
Next

Print #FileNum, Text2.Text
Close #FileNum

.InBufferCount = 0

End Select
End If

'Debug.Print "Receive - " & Text2.Text
'DataLog (Text2.Text)

End With
End Sub
 

Hi,
You have to set Rthreshold value to number of characters expected to be collected before the event.

Regards,
Laktronics
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top