I am using the append function on a text file and it adds in everything with double quotes. How do I suppress them? Here is are my codes and an example:
My module calls out a form which adds a user defined header before going back into the sub in the module.
Sub Calibration()
Dim intPortID As Integer
Dim lngStatus As Long
Dim strdata As String
Dim fileData As String
Dim errorData As String
Dim portData As String
Dim count As Integer
Dim fso, MyFile
'Create a file for calibration.
Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile = fso.CreateTextFile("C:\BCNGEN\CALIBRATION.URT", True)
MyFile.Close
Cal1.Show
Open "C:\BCNGEN\CALIBRATION.URT" For Append As #1
'User selected COM-Port. Default set to 1.
intPortID = Sheets("Calibration").Range("E2").Value
'Set COM-Port Properties.
lngStatus = CommOpen(intPortID, "COM" & CStr(intPortID), _
"baud=38400 parity=N data=8 stop=1")
'Start Calibration.
'Reset unit.
strdata = (Worksheets("Calibration").Cells(2, 3).Value & vbCr)
lngStatus = CommWrite(intPortID, strdata)
lngStatus = CommRead(intPortID, portData, 4)
'Write until 23.
Dim i As Integer
Do Until i = 71
For i = 2 To 71
'Reset count to 0.
count = 0
Do Until count = 3
'Send information to UART.
strdata = (Worksheets("Calibration").Cells(i, 3).Value & vbCr)
If Len(strdata) < 11 Then
GoTo blankcell
End If
lngStatus = CommWrite(intPortID, strdata)
'Read from COM-Port.
lngStatus = CommRead(intPortID, portData, 4)
'MsgBox (portData)
'Check for Valid data
If portData = vbCrLf & "*" Then
'Check Data from UART.
strdata = (Worksheets("Calibration").Cells(i, 4).Value & vbCr)
lngStatus = CommWrite(intPortID, strdata)
Application.Wait (Now + 0.000002)
'Read from COM-Port.
lngStatus = CommRead(intPortID, portData, 10)
MsgBox (portData)
If portData = (Worksheets("Calibration").Cells(i, 2).Value & vbCrLf & "*") Then
'Write the information to the output-file.
fileData = (Worksheets("Calibration").Cells(i, 1).Value & " passed" & vbCr)
'MyFile.WriteLine (fileData)
Write #1, fileData
Else
fileData = (Worksheets("Calibration").Cells(i, 1).Value & " failed" & vbCr)
'MyFile.WriteLine (fileData)
Write #1, fileData
End If
Exit Do
Private Sub CommandButton1_Click()
Open "C:\BCNGEN\CALIBRATION.URT" For Append As #1
Write #1, "Calibration Results"
Write #1, "Name:" & vbTab & vbTab & vbTab & TextBox1.Value & vbCrLf & "Part Number:" & vbTab & TextBox2.Value & vbCrLf & "Serial Number:" & vbTab & TextBox3.Value
Close #1
Unload Me
End Sub
OUTPUT IN FILE:
"Calibration Results"
"Name: Lisa
Part Number: 718-7100-502
Serial Number: 001"
"w 0000 0000*"
"w 0000 0000*"
I want to remove those quotes. I dont know why it adds them
Bookmarks