Imports System.Threading
Public Class RSIform
Dim MonThread As New Thread(AddressOf Rangeloops)
Private Sub TreeView_Insp_Records_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView_Insp_Records.AfterSelect
MonThread.Start()
End Sub
Private Sub Rangeloops()
Clearalltextbox() 'Make sure all fields are empty while switching form child to child
TextBox_selectednodes.Text = TreeView_Insp_Records.SelectedNode.Text
Ping_network()
Dim row As Long
row = 1
Dim Inspfred As Worksheet
Dim Inspchris As Worksheet
Dim Inspjr As Worksheet
Dim Inspluc As Worksheet
Dim Inspted As Worksheet
Inspfred = Form1.xlWorkBook.Sheets("Inspfred")
Inspchris = Form1.xlWorkBook.Sheets("Inspchris")
Inspjr = Form1.xlWorkBook.Sheets("Inspjr")
Inspluc = Form1.xlWorkBook.Sheets("Inspluc")
Inspted = Form1.xlWorkBook.Sheets("Inspted")
Dim rg1 As Range 'Range pour fred
Dim rg2 As Range 'Range pour chris
Dim rg3 As Range 'Range pour jr
Dim rg4 As Range 'Range pour luc
Dim rg5 As Range 'Range pour ted
rg1 = Inspfred.Range("C1").CurrentRegion 'Loop les valeurs situées dans la colonne C pour Inspfred (dans la sheet Inspfred)
rg2 = Inspchris.Range("C1").CurrentRegion 'Loop les valeurs situées dans la colonne C pour Inspchris (dans la sheet Inspchris)
rg3 = Inspjr.Range("C1").CurrentRegion 'Loop les valeurs situées dans la colonne C pour Inspjr (dans la sheet Inspjr)
rg4 = Inspluc.Range("C1").CurrentRegion 'Loop les valeurs situées dans la colonne C pour Inspluc (dans la sheet Inspluc)
rg5 = Inspted.Range("C1").CurrentRegion 'Loop les valeurs situées dans la colonne C pour Inspted (dans la sheet Inspted)
Dim i As Long
For i = 1 To rg1.Rows.Count 'Range pour Inspfred
If rg1.Cells(i, 3).value = TreeView_Insp_Records.SelectedNode.Text Then ' Si les valeurs colonne C = node sélectionner dans treeview
TextBox_RDIMS.Text = rg1.Cells(i, 19).value
TextBox_RSIG.Text = rg1.Cells(i, 18).value
TextBox_LocationNAME.Text = rg1.Cells(i, 4).value
TextBox_Type.Text = rg1.Cells(i, 6).value
TextBox_ABC.Text = rg1.Cells(i, 7).value
TextBox_Railway.Text = rg1.Cells(i, 5).value
TextBox_issue.Text = rg1.Cells(i, 8).value
TextBox_InspFROM.Text = rg1.Cells(i, 9).value
TextBox_InspTO.Text = rg1.Cells(i, 10).value
TextBox_Total_Insp.Text = rg1.Cells(i, 11).value
TextBox_Date.Text = rg1.Cells(i, 12).value
TextBox_Year.Text = rg1.Cells(i, 2).value
TextBox_Lead_RSI.Text = rg1.Cells(i, 15).value
TextBox_2nd_RSI.Text = rg1.Cells(i, 16).value
TextBox_Letterofconcern.Text = rg1.Cells(i, 21).value
TextBox_Prenotice.Text = rg1.Cells(i, 23).value
TextBox_notice_order.Text = rg1.Cells(i, 26).value
TextBox_NAIAT.Text = rg1.Cells(i, 28).value
TextBox_AMP.Text = rg1.Cells(i, 29).value
TextBox_letterofwarning.Text = rg1.Cells(i, 31).value
TextBox_Comments.Text = rg1.Cells(i, 32).value
'RadioBtn_TAV.Checked = True
'RadioBtn_LONE.Checked = False
'RadioBtn_WALK.Checked = False
row = row + 1
Exit For
End If
Next
'And all my other loops
MonThread.Abort()
End Select
End Sub