About Rsview32 VBA Report

In December

Member
Join Date
Dec 2009
Location
anshan liaoning province
Posts
3
Hello,I have a problem about Rsview32 report, which had been discussed in this forum ,but I am a beginner about VBA report.I have a program,it needs following function:
1.day report.when it is 12:00 to 12:01 pm,it has generate a new report whose name is the date,that is the day report.
2.month report,the month report includes:average value of all parameter(per day),and accumulation value of all parameter(per day) whose name is the month.I cannot realise the month accumulation.
3.Every 10 minutes( one hour six times),it collects the tag value,then export to CSV. format,how can I realise it? who can help me,give me correct program code,thank u very much.

the primary program is like
Public Sub WriteCSVLogFile()
Dim F1 As Tag
Dim F2 As Tag
Dim F3 As Tag
Dim F4 As Tag
Dim F5 As Tag
Dim F6 As Tag
Dim F7 As Tag
Dim F8 As Tag
Dim W1 As Tag
Dim W2 As Tag
Dim W3 As Tag
Dim W4 As Tag
Dim W5 As Tag
Dim W6 As Tag
Dim W7 As Tag
Dim W8 As Tag
Dim SYSTEMRUN As Tag
Dim LogDate As Date
Dim LogFile As Integer
Dim HeaderTrack As Integer
Dim HeaderPrint As Integer
On Error GoTo catch
MkDir ("C:\WasteWater")
Check:
'Check to see if the header needs to be inserted.
'HeaderTrack is an Integer bit that is set to 0 if it is 12:00 AM, otherwise set = 1.
If ((Format$(Time, "hh:mm:ss") >= #12:00:00 PM#) And (Format$(Time, "hh:mm:ss") <= #12:01:00 PM#)) Or (HeaderPrint = 0) Then
HeaderTrack = 0
Else: HeaderTrack = 1
End If
Set F1 = gProject.TagDb("fenqingshui\01")
Set F2 = gProject.TagDb("fenqingshui\02")
Set F3 = gProject.TagDb("fenqingshui\03")
Set F4 = gProject.TagDb("fenqingshui\04")
Set F5 = gProject.TagDb("fenqingshui\05")
Set F6 = gProject.TagDb("fenqingshui\06")
Set F7 = gProject.TagDb("fenqingshui\07")
Set F8 = gProject.TagDb("fenqingshui\08")
Set W1 = gProject.TagDb("wushui\01")
Set W2 = gProject.TagDb("wushui\02")
Set W3 = gProject.TagDb("wushui\03")
Set W4 = gProject.TagDb("wushui\04")
Set W5 = gProject.TagDb("wushui\05")
Set W6 = gProject.TagDb("wushui\06")
Set W7 = gProject.TagDb("wushui\07")
Set W8 = gProject.TagDb("wushui\08")
'Set LogDate equal to current date function.
LogDate = Date
'Get available file number
LogFile = FreeFile
'Open File for writing to and name file with format date.csv
Open "C:\WasteWater\" & Format$(LogDate, "mmddyy") & ".csv" For Append As #LogFile
If HeaderTrack = 1 Then
Print #LogFile, " TIME"; ","; _
"F1 flow"; ","; _
"temperature"; ","; _
"焦化水悬浮物"; ","; _
"焦化污水PH"; ","; _
"FCOD"; ","; _
"焦化氨氮"; ","; _
"焦化污水氰化物"; ","; _
"焦化挥发酚"; ","; _
"生产污水流量"; ","; _
"总排放污水温度"; ","; _
"ccc"; ","; _
"www"; ","; _
"COD"; ","; _
"污水氨氮含量"; ","; _
"污水油含量"; ","
End If
n = 0
i=minute(Date)
Dim i as Integer
Do While HeaderTrack = 0
for i =0 to 60 step 10
n=n+1
'Insert the Header into the csv file between 12:00 and 12:01 PM (or next time program runs) and then insert the data in the correct columns.

'Insert data into column if the header was just inserted
Print #LogFile, Format$(Time, "hh:mm:ss"); ","; _
Format(F1.Value, "###0"); ","; _
Format(F2.Value, "#0"); ","; _
Format(F3.Value, "#0"); ","; _
Format(F4.Value, "####0.0"); ","; _
Format(F5.Value, "#0.0"); ","; _
Format(F6.Value, "###0.0"); ","; _
Format(F7.Value, "###0.0"); ","; _
Format(F8.Value, "#######0"); ","; _
Format(W1.Value, "0.00"); ","; _
Format(W2.Value, "#0"); ","; _
Format(W3.Value, "#0"); ","; _
Format(W4.Value, "###0"); ","; _
Format(W5.Value, "###0"); ","; _
Format(W6.Value, "###0"); ","; _
Format(W7.Value, "###0"); ","
HeaderPrint = 1
next i
Loop
Close #LogFile

'If the directory already exists, skip to the next line
'Error 75 is directory already created or exists.
catch: 'Error handling routine
If Err.Number = 75 Then
Err.Clear
GoTo Check
Else:
If Err.Number = 4170 Then
Print "Error#4170--Communications driver is not available."
'roErrorTagEvent (4170) - an error occurred while waiting for the operation to complete
Err.Clear
GoTo Check
End If 'End errror #4170
Err.Clear
End If 'End errror handling
End Sub
 

Similar Topics

Good friends, I'm new to the forum, I'm working with RSview32, someone can help me how to make a macro in VBA, to save some data in Excel. to...
Replies
6
Views
1,959
We were given RSView32 project files, for quoting, that will be converted to FTView SE. Unfortunately the project has VBA references that were...
Replies
9
Views
4,325
Hi, I got a RSview32 project from site with VBA scripts and trying to run on my local machine to make some graphical changes. VB scripts are used...
Replies
6
Views
3,508
Please somebody upload this manual on another site or forward me 51770 - Sample VBA: Exercise in migrating an RSView32 application with VBA to...
Replies
8
Views
4,917
Hello all, New to the forums here and glad to find this oasis of RSView/FactoryTalk info! I have a basic VB question I hope can be answered...
Replies
4
Views
2,314
Back
Top Bottom