Anda di halaman 1dari 2

Untitled

Dim recordcount,recordcount1 As Variant


Dim test As Integer
Private Type Index
Tag_Time1 As String * 8
End Type
Private Type Resources
Tag_Time As String * 8
Tag_Date As String * 10
Tag_Pen1 As Double ' SK 1
Tag_Pen2 As Double' SK 2
Tag_Pen3 As Double' Body 2
Tag_Pen4 As Double' Body 3A
Tag_Pen5 As Double' Body 3B
Tag_Pen6 As Double' Body 4A
Tag_Pen7 As Double' Body 4B
Tag_Pen8 As Double' Brix
Tag_Pen9 As Double' Spare
Tag_Pen10 As Double
' Spare
End Type
Private cResources As Resources
Private cIndex As Index
Sub Main
Dim i1,i2,i3,i4,i5,i6,i7,i8,i9,i10 As Double
i1 = SK1_PV
i2 = SK2_PV
i3 = Body1_PV
i4 = Body2A_PV
i5 = Body2B_PV
i6 = Body3A_PV
i7 = Body3B_PV
i8 = Brix_PV
i9 = 0
i10= 0
Call FillData(i1,i2,i3,i4,i5,i6,i7,i8,i9,i10)
Call SaveData()
End Sub
Private Sub FillData(i1,i2,i3,i4,i5,i6,i7,i8,i9,i10 As Double)
With cIndex
.Tag_Time1 = Format(Now(),"HH:mm:ss")
End With
With cResources
.Tag_Time = Format(Now(),"HH:mm:ss")
.Tag_Date = Format(Now(),"DD/MM/YYYY")
.Tag_Pen1 = i1
.Tag_Pen2 = i2
.Tag_Pen3 = i3
.Tag_Pen4 = i4
.Tag_Pen5 = i5
.Tag_Pen6 = i6
.Tag_Pen7 = i7
.Tag_Pen8 = i8
.Tag_Pen9 = i9
.Tag_Pen10 = i10
End With
End Sub
Private Sub SaveData()
Dim CurrentPos As Integer
Page 1

Untitled
Dim nFileNum As Integer
Dim iFileNum As Integer
Dim nLen As Integer, i As Long, lCount As Long
Dim savefilename As String
Dim saveindexfile As String
On Error Resume Next
On Error GoTo 0
nFileNum = FreeFile
iFileNum = FreeFile
savefilename = "D:\HISTORY_TREND1\" & Format(Now(),"yyyymmdd") & "_Trend.dat"
saveindexfile = "D:\HISTORY_TREND1\" & Format(Now(),"yyyymmdd") & ".ind"
Open saveindexfile For Random As #iFileNum Len = Len(cIndex)
recordcount = Int(LOF(iFileNum) / Len(cIndex)) + 1
Put #iFileNum,recordcount,cIndex
Close #iFileNum
Open savefilename For Random As #nFileNum Len = Len(cResources)
recordcount1 = Int(LOF(nFileNum) / Len(cResources)) + 1
Put #nFileNum,recordcount1,cResources
Close #nFileNum
End Sub

Page 2

Anda mungkin juga menyukai