diff --git a/Databas.xlsx b/Databas.xlsx index f90c48b..8fb5fa4 100644 Binary files a/Databas.xlsx and b/Databas.xlsx differ diff --git a/Wardrobe/GUI.vb b/Wardrobe/GUI.vb index e8d1585..78ce508 100644 --- a/Wardrobe/GUI.vb +++ b/Wardrobe/GUI.vb @@ -2,8 +2,8 @@ Imports Excel = Microsoft.Office.Interop.Excel Public Class GUI - Public Shared filepath As String = "C:\Users\Anton\Documents\Exjobb" - 'Public Shared filepath As String = "C:\Users\xperd\OneDrive\Dokument\Exjobb" + 'Public Shared filepath As String = "C:\Users\Anton\Documents\Exjobb" + Public Shared filepath As String = "C:\Users\xperd\Documents" Dim filesFolder As String = filepath ' Hämta från settings Dim HLCtFolder As String = filepath & "\X2021" ' Hämta från settings @@ -62,6 +62,7 @@ Public Class GUI Create_StartPoints() Program.Load_XCC(filesFolder, HLCtFolder) + excelWB = excelApp.Workbooks.Open(HLCtFolder & "\Databas.xlsx") End Sub ' --- Retrive parameters for the drawing box --- @@ -318,19 +319,41 @@ Public Class GUI gratingType = ComboBox_TypeChooser.Text ComboBox_Material.Enabled = True ComboBox_Material.Items.Clear() - If gratingType = "Pressure Welded" Then - ComboBox_Material.Items.Add("Standard") - ComboBox_Material.Items.Add("Acid-proof") - ComboBox_Material.Items.Add("Stainless Steel (Pickled)") - ComboBox_Material.Items.Add("Stainless Steel (Untreated)") - ComboBox_Material.Items.Add("Untreated") - Else - ComboBox_Material.Items.Add("Standard") - ComboBox_Material.Items.Add("Stainless Steel (Pickled)") - ComboBox_Material.Items.Add("Stainless Steel (Untreated)") - ComboBox_Material.Items.Add("Aluminum") - ComboBox_Material.Items.Add("Untreated") - End If + + Dim materialSheet As Excel.Worksheet + materialSheet = excelWB.Sheets("Material") + Dim typeColumn As Integer = 0 + Dim columnCounter As Integer = 1 + While typeColumn = 0 + If materialSheet.Cells(1, columnCounter).value = "TYPE" Then + typeColumn = materialSheet.Cells(1, columnCounter).column + + End If + columnCounter = columnCounter + 1 + End While + + Dim materialColumn As Integer = 0 + columnCounter = 1 + While materialColumn = 0 + If materialSheet.Cells(1, columnCounter).value = "MATERIAL" Then + materialColumn = materialSheet.Cells(1, columnCounter).column + + End If + columnCounter = columnCounter + 1 + End While + + Dim typeInExcel As String + Dim rowCounter As Integer = 2 + typeInExcel = materialSheet.Cells(rowCounter, typeColumn).value + While typeInExcel <> "" + If gratingType = typeInExcel Then + ComboBox_Material.Items.Add(materialSheet.Cells(rowCounter, materialColumn).Value) + + End If + rowCounter = rowCounter + 1 + typeInExcel = materialSheet.Cells(rowCounter, typeColumn).value + End While + ComboBox_Material.Text = ComboBox_Material.Items(0) End Sub @@ -459,9 +482,6 @@ Public Class GUI End If End Sub - - - ' --- Check if width is a number --- Private Sub ComboBox_Width_KeyPress(sender As Object, e As KeyPressEventArgs) Handles ComboBox_Width.KeyPress Check_IfNumber(e) @@ -682,7 +702,7 @@ Public Class GUI Private Sub SettingsButton_Click(sender As Object, e As EventArgs) Handles SettingsButton.Click 'Program.Update_KB() - excelWB = excelApp.Workbooks.Open(HLCtFolder & "\Databas.xlsx") + excelSheet = excelWB.Sheets("Pressure_welded") 'Call sheet by name 'excelSheet = excelWB.Sheets(1) 'Call sheet by number