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 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626
|
Imports System.ComponentModel
Imports System.IO
Imports System.Text
Imports Excel = Microsoft.Office.Interop.Excel
Public Class DEMO
'Dim pathwriter As StreamWriter
Dim reset As Boolean = False 'for reset bouton
Dim resetcounter As Integer = 0
Dim flagtimer As Boolean = False 'flag to activate the date registration
Dim Fronts, Backs, Elem, Screws, Boxes, Wires, Poly, Wf, others As Integer 'flags
Dim i As Integer = 1 'counter used to count the number of line in the excel file
Dim k As Integer = 1 'counter used like i but for downtime
Dim cellN As String 'Cell Number
Dim df1, df2, db1, db2, de1, de2, ds1, ds2, dx1, dx2, dw1, dw2, dp1, dp2, dwf1, dwf2, do1, do2, path, path2, path3 As String
Dim df, dfR, dfe, db, dbr, dbe, de, der, dee, ds, dsr, dse, dx, dxr, dxe, dw, dwr, dwe, dp, dpr, dpe, dwf, dwfr, dwfe, dot, dotr, dote As Date
Dim dreal, dreale As Date 'used to calcul the real downtime
Dim dstop As String 'real downtime
Dim ApExcel As New Excel.Application 'Application Excel
Dim wbExcel As Excel.Workbook 'Classeur Excel
Dim wsExcel As Excel.Worksheet 'Feuille Excel
'Dim mRow As Integer = CInt(ws.Cells.SpecialCells(Excel.XlCellType.xlCellTypeLastCell).Row)
'Dim mColumn As Integer = CInt(ws.Cells.SpecialCells(Excel.XlCellType.xlCellTypeLastCell).Column)
Private Sub butReset_Click(sender As Object, e As EventArgs) Handles butReset.Click
'Reset button increase/set a flag to have the status of reset
If resetcounter = 0 Then
resetcounter = resetcounter + 1
reset = True
butReset.BackColor = Color.Green
Else
resetcounter = 0
reset = False
butReset.BackColor = Color.LightGray
End If
End Sub
Private Sub butOthers_Click(sender As Object, e As EventArgs) Handles butOthers.Click
'If the operator click once on the button, this one become amber : that's mean that the cell is running out of parts
'when the operator click a second time, the button become red and the date is saved
'when reset button is pressed, it will light off the buttons pressed next, the date will be registered again : the difference of the 2 dates gives the real downtime
'for the cell
If reset = False Then
If others = 0 Then
butOthers.BackColor = Color.Orange
others = others + 1
dot = DateTime.Now
ElseIf others = 1 Then
butOthers.BackColor = Color.Red
others = others + 1
dotr = DateTime.Now
If flagtimer = False Then
flagtimer = True
dreal = DateTime.Now
End If
End If
ElseIf reset = True Then
others = 0
butOthers.BackColor = Color.LightGray
If Fronts = 0 And Backs = 0 And Elem = 0 And Screws = 0 And Boxes = 0 And Wires = 0 And Poly = 0 And Wf = 0 And others = 0 Then
flagtimer = False
dreale = DateTime.Now
dstop = DateDiff(DateInterval.Second, dreal, dreale)
'pathwriter = New StreamWriter(path2, True, Encoding.Unicode)
'pathwriter.WriteLine("Stoppage time of " & "Cell N" & cellN & "; " & TimeSpan.FromSeconds(dstop).ToString("hh\:mm\:ss"))
'pathwriter.Close()
ApExcel.Workbooks.Open(path3)
ApExcel.Sheets(2).select
ApExcel.Cells(k, 1) = cellN
ApExcel.Cells(k, 2) = TimeSpan.FromSeconds(dstop).ToString("hh\:mm\:ss")
ApExcel.ActiveWorkbook.Close(True)
ApExcel.Quit()
k = k + 1
End If
dote = DateTime.Now
do1 = DateDiff(DateInterval.Second, dotr, dote)
do2 = DateDiff(DateInterval.Second, dot, dote)
'pathwriter = New StreamWriter(path, True, Encoding.Unicode)
'pathwriter.WriteLine("Cell" & cellN & " ; " & "Others" & " ; " & dot & " ; " & TimeSpan.FromSeconds(do2).ToString("hh\:mm\:ss") & " ; " & dotr & " ; " & TimeSpan.FromSeconds(do1).ToString("hh\:mm\:ss"))
'pathwriter.Close()
ApExcel.Workbooks.Open(path3)
ApExcel.Sheets(1).select
ApExcel.Cells(i, 1) = cellN
ApExcel.Cells(i, 2) = "others"
ApExcel.Cells(i, 3) = dot
ApExcel.Cells(i, 4) = TimeSpan.FromSeconds(do2).ToString("hh\:mm\:ss")
ApExcel.Cells(i, 5) = dotr
ApExcel.Cells(i, 6) = TimeSpan.FromSeconds(do1).ToString("hh\:mm\:ss")
i = i + 1
ApExcel.ActiveWorkbook.Close(True)
ApExcel.Quit()
End If
End Sub
Private Sub butWires_Click(sender As Object, e As EventArgs) Handles butWires.Click
If reset = False Then
If Wires = 0 Then
butWires.BackColor = Color.Orange
Wires = Wires + 1
dw = DateTime.Now
ElseIf Wires = 1 Then
butWires.BackColor = Color.Red
Wires = Wires + 1
dwr = DateTime.Now
If flagtimer = False Then
flagtimer = True
dreal = DateTime.Now
End If
End If
ElseIf reset = True Then
Wires = 0
butWires.BackColor = Color.LightGray
If Fronts = 0 And Backs = 0 And Elem = 0 And Screws = 0 And Boxes = 0 And Wires = 0 And Poly = 0 And Wf = 0 And others = 0 Then
flagtimer = False
dreale = DateTime.Now
dstop = DateDiff(DateInterval.Second, dreal, dreale)
'pathwriter = New StreamWriter(path2, True, Encoding.Unicode)
'pathwriter.WriteLine("Stoppage time of " & "Cell N" & cellN & "; " & TimeSpan.FromSeconds(dstop).ToString("hh\:mm\:ss"))
'pathwriter.Close()
ApExcel.Workbooks.Open(path3)
ApExcel.Sheets(2).select
ApExcel.Cells(k, 1) = cellN
ApExcel.Cells(k, 2) = TimeSpan.FromSeconds(dstop).ToString("hh\:mm\:ss")
ApExcel.ActiveWorkbook.Close(True)
ApExcel.Quit()
k = k + 1
End If
dwe = DateTime.Now
dw1 = DateDiff(DateInterval.Second, dwr, dwe)
dw2 = DateDiff(DateInterval.Second, dw, dwe)
'pathwriter = New StreamWriter(path, True, Encoding.Unicode)
'pathwriter.WriteLine("Cell" & cellN & " ; " & "Wires" & " ; " & dw & " ; " & TimeSpan.FromSeconds(dw2).ToString("hh\:mm\:ss") & " ; " & dwr & " ; " & TimeSpan.FromSeconds(dw1).ToString("hh\:mm\:ss"))
'pathwriter.Close()
ApExcel.Workbooks.Open(path3)
ApExcel.Sheets(1).select
ApExcel.Cells(i, 1) = cellN
ApExcel.Cells(i, 2) = "Wires"
ApExcel.Cells(i, 3) = dw
ApExcel.Cells(i, 4) = TimeSpan.FromSeconds(dw2).ToString("hh\:mm\:ss")
ApExcel.Cells(i, 5) = dwr
ApExcel.Cells(i, 6) = TimeSpan.FromSeconds(dw1).ToString("hh\:mm\:ss")
i = i + 1
ApExcel.ActiveWorkbook.Close(True)
ApExcel.Quit()
End If
End Sub
Private Sub ButScrews_Click(sender As Object, e As EventArgs) Handles butScrews.Click
If reset = False Then
If Screws = 0 Then
butScrews.BackColor = Color.Orange
Screws = Screws + 1
ds = DateTime.Now
ElseIf Screws = 1 Then
butScrews.BackColor = Color.Red
Screws = Screws + 1
dsr = DateTime.Now
If flagtimer = False Then
flagtimer = True
dreal = DateTime.Now
End If
End If
ElseIf reset = True Then
butScrews.BackColor = Color.LightGray
Screws = 0
If Fronts = 0 And Backs = 0 And Elem = 0 And Screws = 0 And Boxes = 0 And Wires = 0 And Poly = 0 And Wf = 0 And others = 0 Then
flagtimer = False
dreale = DateTime.Now
dstop = DateDiff(DateInterval.Second, dreal, dreale)
'pathwriter = New StreamWriter(path2, True, Encoding.Unicode)
'pathwriter.WriteLine("Stoppage time of " & "Cell N" & cellN & "; " & TimeSpan.FromSeconds(dstop).ToString("hh\:mm\:ss"))
'pathwriter.Close()
ApExcel.Workbooks.Open(path3)
ApExcel.Sheets(2).select
ApExcel.Cells(k, 1) = cellN
ApExcel.Cells(k, 2) = TimeSpan.FromSeconds(dstop).ToString("hh\:mm\:ss")
ApExcel.ActiveWorkbook.Close(True)
ApExcel.Quit()
k = k + 1
End If
dse = DateTime.Now
ds1 = DateDiff(DateInterval.Second, dsr, dse)
ds2 = DateDiff(DateInterval.Second, ds, dse)
'pathwriter = New StreamWriter(path, True, Encoding.Unicode)
'pathwriter.WriteLine("Cell" & cellN & " ; " & "Screws" & " ; " & ds & " ; " & TimeSpan.FromSeconds(ds2).ToString("hh\:mm\:ss") & " ; " & dsr & " ; " & TimeSpan.FromSeconds(ds1).ToString("hh\:mm\:ss"))
'pathwriter.Close()
ApExcel.Workbooks.Open(path3)
ApExcel.Sheets(1).select
ApExcel.Cells(i, 1) = cellN
ApExcel.Cells(i, 2) = "Screws"
ApExcel.Cells(i, 3) = ds
ApExcel.Cells(i, 4) = TimeSpan.FromSeconds(ds2).ToString("hh\:mm\:ss")
ApExcel.Cells(i, 5) = dsr
ApExcel.Cells(i, 6) = TimeSpan.FromSeconds(ds1).ToString("hh\:mm\:ss")
i = i + 1
ApExcel.ActiveWorkbook.Close(True)
ApExcel.Quit()
End If
End Sub
Private Sub ButPoly_Click(sender As Object, e As EventArgs) Handles butPoly.Click
If reset = False Then
If Poly = 0 Then
butPoly.BackColor = Color.Orange
Poly = Poly + 1
dp = DateTime.Now
ElseIf Poly = 1 Then
butPoly.BackColor = Color.Red
Poly = Poly + 1
dpr = DateTime.Now
If flagtimer = False Then
flagtimer = True
dreal = DateTime.Now
End If
End If
ElseIf reset = True Then
butPoly.BackColor = Color.LightGray
Poly = 0
If Fronts = 0 And Backs = 0 And Elem = 0 And Screws = 0 And Boxes = 0 And Wires = 0 And Poly = 0 And Wf = 0 And others = 0 Then
flagtimer = False
dreale = DateTime.Now
dstop = DateDiff(DateInterval.Second, dreal, dreale)
'pathwriter = New StreamWriter(path2, True, Encoding.Unicode)
'pathwriter.WriteLine("Stoppage time of " & "Cell N" & cellN & "; " & TimeSpan.FromSeconds(dstop).ToString("hh\:mm\:ss"))
'pathwriter.Close()
ApExcel.Workbooks.Open(path3)
ApExcel.Sheets(2).select
ApExcel.Cells(k, 1) = cellN
ApExcel.Cells(k, 2) = TimeSpan.FromSeconds(dstop).ToString("hh\:mm\:ss")
ApExcel.ActiveWorkbook.Close(True)
ApExcel.Quit()
k = k + 1
End If
Poly = 0
dpe = DateTime.Now
dp1 = DateDiff(DateInterval.Second, dpr, dpe)
dp2 = DateDiff(DateInterval.Second, dp, dpe)
'pathwriter = New StreamWriter(path, True, Encoding.Unicode)
'pathwriter.WriteLine("Cell" & cellN & " ; " & "Poly" & " ; " & dp & " ; " & TimeSpan.FromSeconds(dp2).ToString("hh\:mm\:ss") & " ; " & dpr & " ; " & TimeSpan.FromSeconds(dp1).ToString("hh\:mm\:ss"))
'pathwriter.Close()
ApExcel.Workbooks.Open(path3)
ApExcel.Sheets(1).select
ApExcel.Cells(i, 1) = cellN
ApExcel.Cells(i, 2) = "Poly"
ApExcel.Cells(i, 3) = dp
ApExcel.Cells(i, 4) = TimeSpan.FromSeconds(dp2).ToString("hh\:mm\:ss")
ApExcel.Cells(i, 5) = dpr
ApExcel.Cells(i, 6) = TimeSpan.FromSeconds(dp1).ToString("hh\:mm\:ss")
i = i + 1
ApExcel.ActiveWorkbook.Close(True)
ApExcel.Quit()
End If
End Sub
Private Sub butboxes_Click(sender As Object, e As EventArgs) Handles butboxes.Click
If reset = False Then
If Boxes = 0 Then
butboxes.BackColor = Color.Orange
Boxes = Boxes + 1
dx = DateTime.Now
ElseIf Boxes = 1 Then
butboxes.BackColor = Color.Red
Boxes = Boxes + 1
dxr = DateTime.Now
If flagtimer = False Then
flagtimer = True
dreal = DateTime.Now
End If
End If
ElseIf reset = True Then
butboxes.BackColor = Color.LightGray
Boxes = 0
If Fronts = 0 And Backs = 0 And Elem = 0 And Screws = 0 And Boxes = 0 And Wires = 0 And Poly = 0 And Wf = 0 And others = 0 Then
flagtimer = False
dreale = DateTime.Now
dstop = DateDiff(DateInterval.Second, dreal, dreale)
'pathwriter = New StreamWriter(path2, True, Encoding.Unicode)
'pathwriter.WriteLine("Stoppage time of " & "Cell N" & cellN & "; " & TimeSpan.FromSeconds(dstop).ToString("hh\:mm\:ss"))
'pathwriter.Close()
ApExcel.Workbooks.Open(path3)
ApExcel.Sheets(2).select
ApExcel.Cells(k, 1) = cellN
ApExcel.Cells(k, 2) = TimeSpan.FromSeconds(dstop).ToString("hh\:mm\:ss")
ApExcel.ActiveWorkbook.Close(True)
ApExcel.Quit()
k = k + 1
End If
dxe = DateTime.Now
dx1 = DateDiff(DateInterval.Second, dxr, dxe)
dx2 = DateDiff(DateInterval.Second, dx, dxe)
'pathwriter = New StreamWriter(path, True, Encoding.Unicode)
'pathwriter.WriteLine("Cell" & cellN & " ; " & "Boxes" & " ; " & dx & " ; " & TimeSpan.FromSeconds(dx2).ToString("hh\:mm\:ss") & " ; " & dxr & " ; " & TimeSpan.FromSeconds(dx1).ToString("hh\:mm\:ss"))
'pathwriter.Close()
ApExcel.Workbooks.Open(path3)
ApExcel.Sheets(1).select
ApExcel.Cells(i, 1) = cellN
ApExcel.Cells(i, 2) = "Boxes"
ApExcel.Cells(i, 3) = dx
ApExcel.Cells(i, 4) = TimeSpan.FromSeconds(dx2).ToString("hh\:mm\:ss")
ApExcel.Cells(i, 5) = dxr
ApExcel.Cells(i, 6) = TimeSpan.FromSeconds(dx1).ToString("hh\:mm\:ss")
i = i + 1
ApExcel.ActiveWorkbook.Close(True)
ApExcel.Quit()
End If
End Sub
Private Sub butwall_Click(sender As Object, e As EventArgs) Handles butwall.Click
If reset = False Then
If Wf = 0 Then
butwall.BackColor = Color.Orange
Wf = Wf + 1
dwf = DateTime.Now
ElseIf Wf = 1 Then
butwall.BackColor = Color.Red
Wf = Wf + 1
dwfr = DateTime.Now
If flagtimer = False Then
flagtimer = True
dreal = DateTime.Now
End If
End If
ElseIf reset = True Then
butwall.BackColor = Color.LightGray
Wf = 0
If Fronts = 0 And Backs = 0 And Elem = 0 And Screws = 0 And Boxes = 0 And Wires = 0 And Poly = 0 And Wf = 0 And others = 0 Then
flagtimer = False
dreale = DateTime.Now
dstop = DateDiff(DateInterval.Second, dreal, dreale)
'pathwriter = New StreamWriter(path2, True, Encoding.Unicode)
'pathwriter.WriteLine("Stoppage time of " & "Cell N" & cellN & "; " & TimeSpan.FromSeconds(dstop).ToString("hh\:mm\:ss"))
'pathwriter.Close()
ApExcel.Workbooks.Open(path3)
ApExcel.Sheets(2).select
ApExcel.Cells(k, 1) = cellN
ApExcel.Cells(k, 2) = TimeSpan.FromSeconds(dstop).ToString("hh\:mm\:ss")
ApExcel.ActiveWorkbook.Close(True)
ApExcel.Quit()
k = k + 1
End If
dwfe = DateTime.Now
dwf1 = DateDiff(DateInterval.Second, dwfr, dwfe)
dwf2 = DateDiff(DateInterval.Second, dwf, dwfe)
'pathwriter = New StreamWriter(path, True, Encoding.Unicode)
'pathwriter.WriteLine("Cell" & cellN & " ; " & "Wallframes" & " ; " & dwf & " ; " & TimeSpan.FromSeconds(dwf2).ToString("hh\:mm\:ss") & " ; " & dwfr & " ; " & TimeSpan.FromSeconds(dwf1).ToString("hh\:mm\:ss"))
'pathwriter.Close()
ApExcel.Workbooks.Open(path3)
ApExcel.Sheets(1).select
ApExcel.Cells(i, 1) = cellN
ApExcel.Cells(i, 2) = "WallFrames"
ApExcel.Cells(i, 3) = dwf
ApExcel.Cells(i, 4) = TimeSpan.FromSeconds(dwf2).ToString("hh\:mm\:ss")
ApExcel.Cells(i, 5) = dwfr
ApExcel.Cells(i, 6) = TimeSpan.FromSeconds(dwf1).ToString("hh\:mm\:ss")
i = i + 1
ApExcel.ActiveWorkbook.Close(True)
ApExcel.Quit()
End If
End Sub
Private Sub butElem_Click(sender As Object, e As EventArgs) Handles butElem.Click
If reset = False Then
If Elem = 0 Then
butElem.BackColor = Color.Orange
Elem = Elem + 1
de = DateTime.Now
ElseIf Elem = 1 Then
butElem.BackColor = Color.Red
Elem = Elem + 1
der = DateTime.Now
If flagtimer = False Then
flagtimer = True
dreal = DateTime.Now
End If
End If
ElseIf reset = True Then
butElem.BackColor = Color.LightGray
Elem = 0
If Fronts = 0 And Backs = 0 And Elem = 0 And Screws = 0 And Boxes = 0 And Wires = 0 And Poly = 0 And Wf = 0 And others = 0 Then
flagtimer = False
dreale = DateTime.Now
dstop = DateDiff(DateInterval.Second, dreal, dreale)
'pathwriter = New StreamWriter(path2, True, Encoding.Unicode)
'pathwriter.WriteLine("Stoppage time of " & "Cell N" & cellN & "; " & TimeSpan.FromSeconds(dstop).ToString("hh\:mm\:ss"))
'pathwriter.Close()
ApExcel.Workbooks.Open(path3)
ApExcel.Sheets(2).select
ApExcel.Cells(k, 1) = cellN
ApExcel.Cells(k, 2) = TimeSpan.FromSeconds(dstop).ToString("hh\:mm\:ss")
ApExcel.ActiveWorkbook.Close(True)
ApExcel.Quit()
k = k + 1
End If
dee = DateTime.Now
de1 = DateDiff(DateInterval.Second, der, dee)
de2 = DateDiff(DateInterval.Second, de, dee)
'pathwriter = New StreamWriter(path, True, Encoding.Unicode)
'pathwriter.WriteLine("Cell" & cellN & " ; " & "Elements" & " ; " & de & " ; " & TimeSpan.FromSeconds(de2).ToString("hh\:mm\:ss") & " ; " & der & " ; " & TimeSpan.FromSeconds(de1).ToString("hh\:mm\:ss"))
'pathwriter.Close()
ApExcel.Workbooks.Open(path3)
ApExcel.Sheets(1).select
ApExcel.Cells(i, 1) = cellN
ApExcel.Cells(i, 2) = "Elements"
ApExcel.Cells(i, 3) = de
ApExcel.Cells(i, 4) = TimeSpan.FromSeconds(de2).ToString("hh\:mm\:ss")
ApExcel.Cells(i, 5) = der
ApExcel.Cells(i, 6) = TimeSpan.FromSeconds(de1).ToString("hh\:mm\:ss")
i = i + 1
ApExcel.ActiveWorkbook.Close(True)
ApExcel.Quit()
End If
End Sub
Private Sub butBack_Click(sender As Object, e As EventArgs) Handles butBack.Click
If reset = False Then
If Backs = 0 Then
butBack.BackColor = Color.Orange
Backs = Backs + 1
db = DateTime.Now
ElseIf Backs = 1 Then
butBack.BackColor = Color.Red
Backs = Backs + 1
dbr = DateTime.Now
If flagtimer = False Then
flagtimer = True
dreal = DateTime.Now
End If
End If
ElseIf reset = True Then
butBack.BackColor = Color.LightGray
Backs = 0
If Fronts = 0 And Backs = 0 And Elem = 0 And Screws = 0 And Boxes = 0 And Wires = 0 And Poly = 0 And Wf = 0 And others = 0 Then
flagtimer = False
dreale = DateTime.Now
dstop = DateDiff(DateInterval.Second, dreal, dreale)
'pathwriter = New StreamWriter(path2, True, Encoding.Unicode)
'pathwriter.WriteLine("Stoppage time of " & "Cell N" & cellN & "; " & TimeSpan.FromSeconds(dstop).ToString("hh\:mm\:ss"))
'pathwriter.Close()
ApExcel.Workbooks.Open(path3)
ApExcel.Sheets(2).select
ApExcel.Cells(k, 1) = cellN
ApExcel.Cells(k, 2) = TimeSpan.FromSeconds(dstop).ToString("hh\:mm\:ss")
ApExcel.ActiveWorkbook.Close(True)
ApExcel.Quit()
k = k + 1
End If
dbe = DateTime.Now
db1 = DateDiff(DateInterval.Second, dbr, dbe)
db2 = DateDiff(DateInterval.Second, db, dbe)
'pathwriter = New StreamWriter(path, True, Encoding.Unicode)
'pathwriter.WriteLine("Cell" & cellN & " ; " & "Backs" & " ; " & db & " ; " & TimeSpan.FromSeconds(db2).ToString("hh\:mm\:ss") & " ; " & dbr & " ; " & TimeSpan.FromSeconds(db1).ToString("hh\:mm\:ss"))
'pathwriter.Close()
ApExcel.Workbooks.Open(path3)
ApExcel.Sheets(1).select
ApExcel.Cells(i, 1) = cellN
ApExcel.Cells(i, 2) = "Backs"
ApExcel.Cells(i, 3) = dbe
ApExcel.Cells(i, 4) = TimeSpan.FromSeconds(db2).ToString("hh\:mm\:ss")
ApExcel.Cells(i, 5) = dbr
ApExcel.Cells(i, 6) = TimeSpan.FromSeconds(db1).ToString("hh\:mm\:ss")
i = i + 1
ApExcel.ActiveWorkbook.Close(True)
ApExcel.Quit()
End If
End Sub
Private Sub butFronts_Click(sender As Object, e As EventArgs) Handles butFronts.Click
If reset = False Then
If Fronts = 0 Then
butFronts.BackColor = Color.Orange
Fronts = Fronts + 1
df = DateTime.Now
ElseIf Fronts = 1 Then
butFronts.BackColor = Color.Red
Fronts = Fronts + 1
dfR = DateTime.Now
If flagtimer = False Then
flagtimer = True
dreal = DateTime.Now
End If
End If
ElseIf reset = True Then
butFronts.BackColor = Color.LightGray
Fronts = 0
If Fronts = 0 And Backs = 0 And Elem = 0 And Screws = 0 And Boxes = 0 And Wires = 0 And Poly = 0 And Wf = 0 And others = 0 Then
flagtimer = False
dreale = DateTime.Now
dstop = DateDiff(DateInterval.Second, dreal, dreale)
'pathwriter = New StreamWriter(path2, True, Encoding.Unicode)
'pathwriter.WriteLine("Stoppage time of " & "Cell N" & cellN & "; " & TimeSpan.FromSeconds(dstop).ToString("hh\:mm\:ss"))
'pathwriter.Close()
ApExcel.Workbooks.Open(path3)
ApExcel.Sheets(2).select
ApExcel.Cells(k, 1) = cellN
ApExcel.Cells(k, 2) = TimeSpan.FromSeconds(dstop).ToString("hh\:mm\:ss")
ApExcel.ActiveWorkbook.Close(True)
ApExcel.Quit()
k = k + 1
End If
dfe = DateTime.Now
df1 = DateDiff(DateInterval.Second, dfR, dfe)
df2 = DateDiff(DateInterval.Second, df, dfe)
'pathwriter = New StreamWriter(path, True, Encoding.Unicode)
'pathwriter.WriteLine("Cell" & cellN & " ; " & "Fronts" & " ; " & df & " ; " & TimeSpan.FromSeconds(df2).ToString("hh\:mm\:ss") & " ; " & dfR & " ; " & TimeSpan.FromSeconds(df1).ToString("hh\:mm\:ss"))
'pathwriter.Close()
ApExcel.Workbooks.Open(path3)
ApExcel.Sheets(1).select
ApExcel.Cells(i, 1) = cellN
ApExcel.Cells(i, 2) = "Fronts"
ApExcel.Cells(i, 3) = dfe
ApExcel.Cells(i, 4) = TimeSpan.FromSeconds(df2).ToString("hh\:mm\:ss")
ApExcel.Cells(i, 5) = dfR
ApExcel.Cells(i, 6) = TimeSpan.FromSeconds(df1).ToString("hh\:mm\:ss")
i = i + 1
ApExcel.ActiveWorkbook.Close(True)
ApExcel.Quit()
End If
End Sub
Private Sub DEMO_Load(sender As Object, e As EventArgs) Handles Me.Load
'initialisation
Fronts = 0
Backs = 0
Elem = 0
Screws = 0
Boxes = 0
Wires = 0
Poly = 0
Wf = 0
others = 0
'Choix du numéro de cellule
cellN = InputBox("please, Write a cell number")
While cellN = ""
cellN = InputBox("please, Write a cell number")
End While
''chemin du fichier texte données
'OpenFileDialog2.Filter = "Text (*.txt)|*.txt"
'If OpenFileDialog2.ShowDialog() = Windows.Forms.DialogResult.OK Then
' path = OpenFileDialog2.FileName
'Else
' MsgBox("No file selected, please choose one file", MsgBoxStyle.Exclamation, "No file selected")
'End If
'pathwriter = New StreamWriter(path, True, Encoding.Unicode)
'pathwriter.WriteLine("Cell" & " ; " & "part" & " ; " & "Amber" & " ; " & "Amber time" & " ; " & "RED" & " ; " & "Stoppage")
'pathwriter.Close()
''chemin du fichier texte temps stop total
'OpenFileDialog3.Filter = "Text (*.txt)|*.txt"
'If OpenFileDialog3.ShowDialog() = Windows.Forms.DialogResult.OK Then
' path2 = OpenFileDialog3.FileName
'Else
' MsgBox("No file selected, please choose one file", MsgBoxStyle.Exclamation, "No file selected")
'End If
'chemin du fichier EXCEL DONNEES
OpenFileDialog3.Filter = "Excel Files(.xls)|*.xls| Excel Files(.xlsx)|*.xlsx| Excel Files(*.xlsm)|*.xlsm"
If OpenFileDialog3.ShowDialog() = Windows.Forms.DialogResult.OK Then
path3 = OpenFileDialog3.FileName
Else
MsgBox("No file selected, please choose one file", MsgBoxStyle.Exclamation, "No file selected")
End If
ApExcel.Workbooks.Open(path3)
ApExcel.Sheets(1).select
ApExcel.Cells(i, 1) = "Cell Number"
ApExcel.Cells(i, 2) = "Parts"
ApExcel.Cells(i, 3) = "Amber"
ApExcel.Cells(i, 4) = "Amber Time"
ApExcel.Cells(i, 5) = "Red"
ApExcel.Cells(i, 6) = "Out of part time"
ApExcel.Sheets(2).select
ApExcel.Cells(k, 1) = "Cell Number"
ApExcel.Cells(k, 2) = "Real Stoppage time"
i = i + 1
k = k + 1
ApExcel.ActiveWorkbook.Close(True)
ApExcel.Quit()
End Sub
'Close excel and free the Tablet memory and processor
Private Sub DEMO_Closed(sender As Object, e As EventArgs) Handles Me.Closed
'closing excel
ApExcel.Quit()
'System.Runtime.InteropServices.Marshal.ReleaseComObject(wsExcel)
'System.Runtime.InteropServices.Marshal.ReleaseComObject(wbExcel)
'System.Runtime.InteropServices.Marshal.ReleaseComObject(ApExcel)
ApExcel = Nothing
wbExcel = Nothing
wsExcel = Nothing
'remove excel process which won't close
Call KillAllExcels()
End Sub
Sub KillAllExcels()
Dim proc As System.Diagnostics.Process
For Each proc In System.Diagnostics.Process.GetProcessesByName("EXCEL")
proc.Kill()
Next
End Sub
End Class
'setting in excel to be shared by multiple cells shareworkbook |
Partager