From 0233d1b7581a255df02289adf5c9c5ffb66d6d97 Mon Sep 17 00:00:00 2001 From: Anton Date: Tue, 9 Feb 2021 12:47:24 +0100 Subject: [PATCH] Fixed previously errors and correctly dispose excel app after use --- Wardrobe/GUI.Designer.vb | 5 +++-- Wardrobe/GUI.vb | 14 ++++++++++++-- Wardrobe/GUI_Gratings_Data.vb | 14 ++++++++++++-- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/Wardrobe/GUI.Designer.vb b/Wardrobe/GUI.Designer.vb index f16510f..1d92f11 100644 --- a/Wardrobe/GUI.Designer.vb +++ b/Wardrobe/GUI.Designer.vb @@ -246,7 +246,7 @@ Partial Class GUI 'Button_Square ' Me.Button_Square.Location = New System.Drawing.Point(971, 68) - Me.Button_Square.Margin = New System.Windows.Forms.Padding(4, 4, 4, 4) + Me.Button_Square.Margin = New System.Windows.Forms.Padding(4) Me.Button_Square.Name = "Button_Square" Me.Button_Square.Size = New System.Drawing.Size(123, 34) Me.Button_Square.TabIndex = 25 @@ -290,6 +290,7 @@ Partial Class GUI 'CheckBox_WholeMeshWidths ' Me.CheckBox_WholeMeshWidths.AutoSize = True + Me.CheckBox_WholeMeshWidths.Enabled = False Me.CheckBox_WholeMeshWidths.Location = New System.Drawing.Point(125, 453) Me.CheckBox_WholeMeshWidths.Margin = New System.Windows.Forms.Padding(3, 2, 3, 2) Me.CheckBox_WholeMeshWidths.Name = "CheckBox_WholeMeshWidths" @@ -328,7 +329,7 @@ Partial Class GUI Me.Controls.Add(Me.DrawingPanel) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon) - Me.Margin = New System.Windows.Forms.Padding(4, 4, 4, 4) + Me.Margin = New System.Windows.Forms.Padding(4) Me.MaximizeBox = False Me.Name = "GUI" Me.Text = "Floor Gratings" diff --git a/Wardrobe/GUI.vb b/Wardrobe/GUI.vb index 3c3a5e4..71697cd 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\Documents" + Public Shared filepath As String = "C:\Users\Anton\Documents\Exjobb" + 'Public Shared filepath As String = "C:\Users\xperd\Documents" Dim excelApp As Excel.Application = New Excel.Application Dim excelWB As Excel.Workbook @@ -21,6 +21,8 @@ Public Class GUI adminClass.loadSettings(GUI_Settings.filesFolder, GUI_Settings.HLCtFolder, "SolidWorks") Get_Database() + + CheckBox_WholeMeshWidths.Checked = True End Sub Private Sub Get_Database() @@ -54,8 +56,16 @@ Public Class GUI End While dataBase.Add(activeSheet.Name, tempDT) + + System.Runtime.InteropServices.Marshal.ReleaseComObject(activeSheet) Next ' HANTERA OLIKA LÄNGDER PÅ COLUMNER + + + excelWB.Close() + excelApp.Quit() + System.Runtime.InteropServices.Marshal.ReleaseComObject(excelWB) + System.Runtime.InteropServices.Marshal.ReleaseComObject(excelApp) End Sub Public Sub Create_TextBox(TextBoxName As String, TextBoxText As String, TextBoxLeft As Integer, TextBoxTop As Integer, TextBoxWidth As Integer) diff --git a/Wardrobe/GUI_Gratings_Data.vb b/Wardrobe/GUI_Gratings_Data.vb index ebbd8c9..7504822 100644 --- a/Wardrobe/GUI_Gratings_Data.vb +++ b/Wardrobe/GUI_Gratings_Data.vb @@ -125,6 +125,11 @@ End Sub Private Shared Sub Update_AvalaibleMeshes() + GUI.ComboBox_Height.Items.Clear() + GUI.ComboBox_Height.Enabled = False + GUI.ComboBox_Thickness.Items.Clear() + GUI.ComboBox_Thickness.Enabled = False + GUI.ComboBox_MeshSize.Items.Clear() Dim meshesDT As DataTable = GUI.dataBase("Meshes") @@ -162,6 +167,9 @@ End Sub Public Shared Sub MeshChanged(sender As Object, e As EventArgs) + GUI.ComboBox_Thickness.Items.Clear() + GUI.ComboBox_Thickness.Enabled = False + GUI.ComboBox_Height.Enabled = True GUI.ComboBox_Height.Items.Clear() gratingMesh = GUI.ComboBox_MeshSize.Text @@ -207,7 +215,7 @@ Next tempList.Sort() - For i = 0 To tempList.Count - 2 + For i = 0 To tempList.Count - 1 GUI.ComboBox_Height.Items.Add(tempList(i)) Next End Sub @@ -256,7 +264,7 @@ Next tempList.Sort() - For i = 0 To tempList.Count - 2 + For i = 0 To tempList.Count - 1 GUI.ComboBox_Thickness.Items.Add(tempList(i)) Next @@ -267,6 +275,8 @@ GUI.ComboBox_Width.Items.Clear() GUI.ComboBox_Length.Enabled = True GUI.ComboBox_Length.Items.Clear() + GUI.CheckBox_WholeMeshWidths.Enabled = True + loadBarThickness = CInt(GUI.ComboBox_Thickness.Text) ' Add Widths