1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
| Public Function timer1_timer()
ReDim temp_buffer(9) As Single
Dim overflow_flag As Integer
Dim i As Integer
Dim t1 As Integer
Dim t2 As Integer
Static deb As Double
If deb = 0 Then deb = Timer
If Timer - deb >= 0.2 Then
If Cells(4, "B").Value < Cells(5, "A").Value Then Application.OnTime Now, "Timer1_Timer"
If UserForm1.CheckBox1 = True Then
If (tc08_handle > 0) Then
If (Not in_timer) Then
in_timer = True
ok = usb_tc08_get_single(tc08_handle, temp_buffer(0), overflow_flag, 0)
If (ok) Then
Cells(4, "A").Value = temp_buffer(0)
Cells(4, "B").Value = temp_buffer(1)
Cells(4, "C").Value = temp_buffer(2)
Range("B4").Select
Selection.Copy
Cells(4, "D").Value = Cells(4, "D").Value + 1
i = Cells(4, "D").Value
t1 = Cells(4, "B").Value
t2 = Cells(4, "C").Value
If t1 > temperaturefindesaisie Then
Cells(i, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End If
End If
in_timer = False
End If
End If
End If
If UserForm1.CheckBox2 = True Then
If (tc08_handle > 0) Then
If (Not in_timer) Then
in_timer = True
ok = usb_tc08_get_single(tc08_handle, temp_buffer(0), overflow_flag, 0)
If (ok) Then
Cells(4, "A").Value = temp_buffer(0)
Cells(4, "B").Value = temp_buffer(1)
Cells(4, "C").Value = temp_buffer(2)
Range("C4").Select
Selection.Copy
If t2 > temperaturefindesaisie Then
Cells(i, 4).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End If
End If
in_timer = False
End If
End If
End If
'remplissage userform2
UserForm2.Label2.Caption = Cells(4, "B").Value & " °c"
UserForm2.Label4.Caption = Cells(4, "C").Value & " °c"
UserForm2.Label6.Caption = Cells(4, "D").Value - 24 & " seconde"
Worksheets("Saisie").ChartObjects("graphique 4").Activate
If i > 0 Then
ActiveChart.SeriesCollection(1).XValues = "=Saisie!$C$25:$C$" & i
ActiveChart.SeriesCollection(1).Values = "=Saisie!$A$25:$A$" & i
ActiveChart.SeriesCollection(2).XValues = "=Saisie!$C$25:$C$" & i
ActiveChart.SeriesCollection(2).Values = "=Saisie!$D$25:$D$" & i
End If
Set LeGraph = Worksheets("Saisie").ChartObjects("graphique 4").Chart
NomImage = ThisWorkbook.Path & Application.PathSeparator & "temp.gif"
LeGraph.Export Filename:=NomImage, FilterName:="GIF"
UserForm2.Image1.Picture = LoadPicture(NomImage)
deb = Timer
End If
End Function |