Fixed previously errors and correctly dispose excel app after use

This commit is contained in:
Anton 2021-02-09 12:47:24 +01:00
parent 83c3984c65
commit 0233d1b758
3 changed files with 27 additions and 6 deletions

View File

@ -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"

View File

@ -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 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)

View File

@ -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