Results 1 to 21 of 21

Thread: Heavy form, need help to solve exceptions, many of....

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2013
    Posts
    336

    Heavy form, need help to solve exceptions, many of....

    here's me full code, i dont get why all the exceptions just after i hit f5 to debug, doesn't state errors, it's all valid code......

    Code:
    Imports System
    Imports System.Collections.Generic
    Imports System.ComponentModel
    Imports System.Data
    Imports System.Drawing
    Imports System.Text
    Imports System.Windows.Forms
    Imports System.IO
    
    Public Class SelectPrograms
    
        'App Name              : Post Install
        'Author                : Chris Reynolds (Chris2k)
        'Creation Date         : 26th March 2013
        '
        'To do:
        '       Add a settings form.........
        '       Improve the editor..........
        '       Add update ability..........
        '       Add icons to app list.......
        '       Fix install order n force install ability....
        '       Add logfile..........................
    
    
        Public Shared Ver As String = " - Version 1.0.1 Beta 2"
        Public Shared programs As Dictionary(Of Integer, program) = New Dictionary(Of Integer, program)
    
        Dim autoStart As Integer = 41
    
        '//Hotkeys
        Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Long) As Integer
    
        Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
            Dim Hotkey_StopAutoStart As Boolean = GetAsyncKeyState(Keys.P)
            Dim Hotkey_ShowEditor As Boolean = GetAsyncKeyState(Keys.F1)
    
            If Hotkey_StopAutoStart = True Then
                CheckBox2.Checked = True
                Seconds_Remain.Enabled = False
                CheckBox2.Enabled = False
            End If
            If Hotkey_ShowEditor = True Then 'Show the editor "F1"
                Editor.Show()
                CheckBox2.Checked = True
                Seconds_Remain.Enabled = False
                CheckBox2.Enabled = False
            End If
        End Sub
    
        Private Sub SelectPrograms_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Me.Text = "Post Install By Chris2k" + Ver
    
            Dim iniFile As String = Application.StartupPath + "\Start\InstallCFG.ini"
    
            If Not (System.IO.File.Exists(iniFile)) Then
                MessageBox.Show("The programs opted for this OS can't be installed as the InstallCFG.ini has not been included...")
            End If
    
            Dim highestIO As Integer = 1
            Dim installOrder As Integer = 0
            For Each ln In IO.File.ReadAllLines(iniFile)
                Try
    
                    If ln.ToLower.StartsWith("install order") Then
                        installOrder = (ln.IndexOf(":"c) + 1)
                        programs.Add(installOrder, New program)
                    ElseIf ln.ToLower.StartsWith("app name") Then
                        programs(installOrder).name = (ln.Substring(ln.IndexOf(":"c) + 1))
                    ElseIf ln.ToLower.StartsWith("description") Then
                        programs(installOrder).desc = (ln.Substring(ln.IndexOf(":"c) + 1))
                        '//ElseIf ln.ToLower.StartsWith("app file size") Then
                        '//programs(installOrder).filesize = getFileSize(program.exepath) (ln.Substring(ln.IndexOf(":"c) + 1))
                    ElseIf ln.ToLower.StartsWith("app file") Then
                        programs(installOrder).exepath = (ln.Substring(ln.IndexOf(":"c) + 1))
                        programs(installOrder).exeicon = getIcon(programs(installOrder).exepath)
                    End If
    
                Catch ex As Exception
    
                End Try
            Next
    
            If (programs.Count > 0) Then
                'CheckBox1.Checked = True
            End If
    
            Dim cOrder As Integer = 0
            Do While (cOrder < (highestIO + 1))
                Try
    
                    If Not programs.ContainsKey(cOrder) Then
                        'TODO: Warning!!! continue If
                    End If
    
                    Dim program As program = programs(cOrder)
                    If Not (program) Is Nothing AndAlso program.name.Length > 0 Then
                        If IO.File.Exists(program.exepath) Then
                            imageList1.Images.Add(program.name, program.exeicon.ToBitmap)
                            Dim pLI As ListViewItem = New ListViewItem(program.name, program.name)
                            pLI.SubItems.Add(program.desc)
                            pLI.SubItems.Add(getFileSize(program.exepath))
                            pLI.SubItems.Add(program.exepath)
                            pLI.Checked = True
                            App_List.Items.Add(pLI)
                        Else
                            '"Installer file for program '" + (program.name + "' could not be found!"
                        End If
                    Else
                        '"Failed to load program from order: " + (cOrder + "..!"
                    End If
                    cOrder = (cOrder + 1)
    
                Catch ex As Exception
    
                End Try
            Loop
    
            Seconds_Remain.Start()
        End Sub
    
        Public Function getFileSize(ByVal path As String) As String
            Dim sizes() As String = New String() {"B", "KB", "MB", "GB"}
            Dim len = My.Computer.FileSystem.GetFileInfo(path).Length
            Dim order As Integer = 0
    
            While ((len >= 1024) _
                        AndAlso (order + (1 < sizes.Length)))
                order = (order + 1)
                len = (len / 1024)
    
            End While
            Return String.Format("{0:0.##} {1}", len, sizes(order))
        End Function
    
        Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged
            If CheckBox2.Checked = True Then
                Seconds_Remain.Enabled = False
                CheckBox2.Enabled = False
            End If
        End Sub
    
        Public Function getIcon(ByVal path As String) As Icon
            Try
                Return Icon.ExtractAssociatedIcon(path)
            Catch ex As System.Exception
                Return Nothing
            End Try
        End Function
    
        Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
            If CheckBox1.Checked Then
                For Each CheckedApp As ListViewItem In App_List.Items
                    CheckedApp.Checked = True
                Next
            Else
                For Each CheckedApp As ListViewItem In App_List.Items
                    CheckedApp.Checked = False
                Next
            End If
            Button1.Text = "Start installing (" + App_List.CheckedItems.Count.ToString + " apps.)"
        End Sub
    
        Private Sub Seconds_Remain_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Seconds_Remain.Tick
            If autoStart > 0 Then
                autoStart -= 1
                CheckBox2.Text = "Stop ticking (" + autoStart.ToString & " Secs Remaining!)"
            ElseIf autoStart = 0 Then
                CheckBox2.Enabled = False
                Label2.Text = "We're gonna install now..."
                InstallPrograms.Show()
            End If
        End Sub
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            If App_List.CheckedItems.Count > 0 Then
                Me.Hide()
                InstallPrograms.Show() '//Load in the form and install checked apps.
            Else
                MessageBox.Show("Nothing selected to install!")
            End If
        End Sub
    
        Private Sub App_List_ItemChecked(ByVal sender As Object, ByVal e As System.Windows.Forms.ItemCheckedEventArgs) Handles App_List.ItemChecked
            Button1.Text = "Start installing (" + App_List.CheckedItems.Count.ToString + " apps.)"
        End Sub
    End Class
    
    Public Class program
    
        Public order As Integer = 0
        Public name As String = ""
        Public desc As String = ""
        Public exepath As String = ""
        Public filesize As Integer
        Public install As Boolean = True
        Public exeicon As Icon = Nothing
    
        Public Sub New()
            MyBase.New()
        End Sub
    End Class
    and here's the exceptions:

    Code:
    A first chance exception of type 'System.Collections.Generic.KeyNotFoundException' occurred in mscorlib.dll
    A first chance exception of type 'System.Collections.Generic.KeyNotFoundException' occurred in mscorlib.dll
    A first chance exception of type 'System.Collections.Generic.KeyNotFoundException' occurred in mscorlib.dll
    A first chance exception of type 'System.Collections.Generic.KeyNotFoundException' occurred in mscorlib.dll
    A first chance exception of type 'System.Collections.Generic.KeyNotFoundException' occurred in mscorlib.dll
    A first chance exception of type 'System.Collections.Generic.KeyNotFoundException' occurred in mscorlib.dll
    A first chance exception of type 'System.Collections.Generic.KeyNotFoundException' occurred in mscorlib.dll
    A first chance exception of type 'System.Collections.Generic.KeyNotFoundException' occurred in mscorlib.dll
    A first chance exception of type 'System.Collections.Generic.KeyNotFoundException' occurred in mscorlib.dll
    A first chance exception of type 'System.Collections.Generic.KeyNotFoundException' occurred in mscorlib.dll
    A first chance exception of type 'System.Collections.Generic.KeyNotFoundException' occurred in mscorlib.dll
    A first chance exception of type 'System.Collections.Generic.KeyNotFoundException' occurred in mscorlib.dll
    A first chance exception of type 'System.Collections.Generic.KeyNotFoundException' occurred in mscorlib.dll
    A first chance exception of type 'System.Collections.Generic.KeyNotFoundException' occurred in mscorlib.dll
    A first chance exception of type 'System.Collections.Generic.KeyNotFoundException' occurred in mscorlib.dll
    A first chance exception of type 'System.Collections.Generic.KeyNotFoundException' occurred in mscorlib.dll
    A first chance exception of type 'System.Collections.Generic.KeyNotFoundException' occurred in mscorlib.dll
    A first chance exception of type 'System.Collections.Generic.KeyNotFoundException' occurred in mscorlib.dll
    A first chance exception of type 'System.Collections.Generic.KeyNotFoundException' occurred in mscorlib.dll
    A first chance exception of type 'System.Collections.Generic.KeyNotFoundException' occurred in mscorlib.dll
    A first chance exception of type 'System.Collections.Generic.KeyNotFoundException' occurred in mscorlib.dll
    A first chance exception of type 'System.Collections.Generic.KeyNotFoundException' occurred in mscorlib.dll
    A first chance exception of type 'System.Collections.Generic.KeyNotFoundException' occurred in mscorlib.dll
    A first chance exception of type 'System.Collections.Generic.KeyNotFoundException' occurred in mscorlib.dll
    A first chance exception of type 'System.Collections.Generic.KeyNotFoundException' occurred in mscorlib.dll
    A first chance exception of type 'System.Collections.Generic.KeyNotFoundException' occurred in mscorlib.dll
    A first chance exception of type 'System.Collections.Generic.KeyNotFoundException' occurred in mscorlib.dll
    A first chance exception of type 'System.Collections.Generic.KeyNotFoundException' occurred in mscorlib.dll
    A first chance exception of type 'System.Collections.Generic.KeyNotFoundException' occurred in mscorlib.dll
    A first chance exception of type 'System.Collections.Generic.KeyNotFoundException' occurred in mscorlib.dll
    A first chance exception of type 'System.Collections.Generic.KeyNotFoundException' occurred in mscorlib.dll
    A first chance exception of type 'System.Collections.Generic.KeyNotFoundException' occurred in mscorlib.dll
    A first chance exception of type 'System.Collections.Generic.KeyNotFoundException' occurred in mscorlib.dll
    A first chance exception of type 'System.Collections.Generic.KeyNotFoundException' occurred in mscorlib.dll
    A first chance exception of type 'System.Collections.Generic.KeyNotFoundException' occurred in mscorlib.dll
    A first chance exception of type 'System.Collections.Generic.KeyNotFoundException' occurred in mscorlib.dll
    + more......

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,415

    Re: Heavy form, need help to solve exceptions, many of....

    the dictionary Programs doesn't contain what you think it contains.
    try stepping through your code, line by line, by pressing F11

  3. #3
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,415

    Re: Heavy form, need help to solve exceptions, many of....

    + check the values Programs contains

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2013
    Posts
    336

    Re: Heavy form, need help to solve exceptions, many of....

    Yea I see now .paul, would u mind helping me fix?

  5. #5
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,415

    Re: Heavy form, need help to solve exceptions, many of....

    i'd need to see your app running.
    could you upload it?

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2013
    Posts
    336

    Re: Heavy form, need help to solve exceptions, many of....


  7. #7
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,415

    Re: Heavy form, need help to solve exceptions, many of....

    this should work now:

    Code:
    Imports System
    Imports System.Collections.Generic
    Imports System.ComponentModel
    Imports System.Data
    Imports System.Drawing
    Imports System.Text
    Imports System.Windows.Forms
    Imports System.IO
    
    Public Class SelectPrograms
    
        'App Name              : Post Install
        'Author                : Chris Reynolds (Chris2k)
        'Creation Date         : 26th March 2013
        '
        'To do:
        '       Add a settings form.........
        '       Improve the editor..........
        '       Add update ability..........
        '       Add icons to app list.......
        '       Fix install order n force install ability....
        '       Add logfile..........................
    
    
        Public Shared Ver As String = " - Version 1.0.1 Beta 2"
        Public Shared programs As Dictionary(Of Integer, program) = New Dictionary(Of Integer, program)
    
        '//Hotkeys
        Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Long) As Integer
    
        Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
            Dim Hotkey_StopAutoStart As Boolean = GetAsyncKeyState(Keys.P)
            Dim Hotkey_ShowEditor As Boolean = GetAsyncKeyState(Keys.F1)
    
            If Hotkey_StopAutoStart = True Then
                CheckBox2.Checked = True
                Seconds_Remain.Enabled = False
                CheckBox2.Enabled = False
            End If
            If Hotkey_ShowEditor = True Then 'Show the editor "F1"
                Editor.Show()
                CheckBox2.Checked = True
                Seconds_Remain.Enabled = False
                CheckBox2.Enabled = False
            End If
        End Sub
    
        Dim autoStart As Integer = 41
    
        Private Sub SelectPrograms_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Me.Text = "Post Install By Chris2k" + Ver
    
            Dim iniFile As String = Application.StartupPath + "\Start\InstallCFG.ini"
    
            If Not (System.IO.File.Exists(iniFile)) Then
                MessageBox.Show("The programs opted for this OS can't be installed as the InstallCFG.ini has not been included...")
            End If
    
            Dim highestIO As Integer = 0
            Dim installOrder As Integer = 0
            For Each ln In IO.File.ReadAllLines(iniFile)
                If ln.StartsWith("#") Or ln.Trim = "" Then Continue For
                Try
                    If ln.ToLower.StartsWith("install order") Then
                        installOrder = CInt(ln.Substring(ln.IndexOf(":"c) + 1))
                        highestIO += 1
                        programs.Add(installOrder, New program)
                    ElseIf ln.ToLower.StartsWith("app name") Then
                        programs(installOrder).name = (ln.Substring(ln.IndexOf(":"c) + 1))
                    ElseIf ln.ToLower.StartsWith("description") Then
                        programs(installOrder).desc = (ln.Substring(ln.IndexOf(":"c) + 1))
                        '//ElseIf ln.ToLower.StartsWith("app file size") Then
                        '//programs(installOrder).filesize = getFileSize(program.exepath) (ln.Substring(ln.IndexOf(":"c) + 1))
                    ElseIf ln.ToLower.StartsWith("app file") Then
                        programs(installOrder).exepath = (ln.Substring(ln.IndexOf(":"c) + 1))
                        programs(installOrder).exeicon = getIcon(programs(installOrder).exepath)
                    End If
    
                Catch ex As Exception
    
                End Try
            Next
    
            If (programs.Count > 0) Then
                'CheckBox1.Checked = True
            End If
    
            Dim cOrder As Integer = 0
            Do While (cOrder < (highestIO + 1))
                Try
    
                    If Not programs.ContainsKey(cOrder) Then
                        'TODO: Warning!!! continue If
                    End If
    
                    Dim program As program = programs(cOrder)
                    If Not (program) Is Nothing AndAlso program.name.Length > 0 Then
                        If IO.File.Exists(program.exepath) Then
                            imageList1.Images.Add(program.name, program.exeicon.ToBitmap)
                            Dim pLI As ListViewItem = New ListViewItem(program.name, program.name)
                            pLI.SubItems.Add(program.desc)
                            pLI.SubItems.Add(getFileSize(program.exepath))
                            pLI.SubItems.Add(program.exepath)
                            pLI.Checked = True
                            App_List.Items.Add(pLI)
                        Else
                            '"Installer file for program '" + (program.name + "' could not be found!"
                        End If
                    Else
                        '"Failed to load program from order: " + (cOrder + "..!"
                    End If
    
    
                Catch ex As Exception
    
                Finally
                    cOrder = (cOrder + 1)
                End Try
            Loop
            Seconds_Remain.Start()
        End Sub
    
        Public Function getFileSize(ByVal path As String) As String
            Dim sizes() As String = New String() {"B", "KB", "MB", "GB"}
            Dim len = My.Computer.FileSystem.GetFileInfo(path).Length
            Dim order As Integer = 0
    
            While ((len >= 1024) _
                        AndAlso (order + (1 < sizes.Length)))
                order = (order + 1)
                len = (len / 1024)
    
            End While
            Return String.Format("{0:0.##} {1}", len, sizes(order))
        End Function
    
        Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged
            If CheckBox2.Checked = True Then
                Seconds_Remain.Enabled = False
                CheckBox2.Enabled = False
            End If
        End Sub
    
        Public Function getIcon(ByVal path As String) As Icon
            Try
                Return Icon.ExtractAssociatedIcon(path)
            Catch ex As System.Exception
                Return Nothing
            End Try
        End Function
    
        Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
            If CheckBox1.Checked Then
                For Each CheckedApp As ListViewItem In App_List.Items
                    CheckedApp.Checked = True
                Next
            Else
                For Each CheckedApp As ListViewItem In App_List.Items
                    CheckedApp.Checked = False
                Next
            End If
            Button1.Text = "Start installing (" + App_List.CheckedItems.Count.ToString + " apps.)"
        End Sub
    
        Private Sub Seconds_Remain_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Seconds_Remain.Tick
            If autoStart > 0 Then
                autoStart -= 1
                CheckBox2.Text = "Stop ticking (" + autoStart.ToString & " Secs Remaining!)"
            ElseIf autoStart = 0 Then
                CheckBox2.Enabled = False
                Label2.Text = "We're gonna install now..."
                InstallPrograms.Show()
            End If
        End Sub
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            If App_List.CheckedItems.Count > 0 Then
                Me.Hide()
                InstallPrograms.Show() '//Load in the form and install checked apps.
            Else
                MessageBox.Show("Nothing selected to install!")
            End If
        End Sub
    
        Private Sub App_List_ItemChecked(ByVal sender As Object, ByVal e As System.Windows.Forms.ItemCheckedEventArgs) Handles App_List.ItemChecked
            Button1.Text = "Start installing (" + App_List.CheckedItems.Count.ToString + " apps.)"
        End Sub
    End Class
    
    Public Class program
    
        Public order As Integer = 0
        Public name As String = ""
        Public desc As String = ""
        Public exepath As String = ""
        Public filesize As Integer
        Public install As Boolean = True
        Public exeicon As Icon = Nothing
    
    End Class

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2013
    Posts
    336

    Re: Heavy form, need help to solve exceptions, many of....

    yea it's working, one problem: it's not listing all the app names, there is 24 in the .ini, it only shows 20 also if i change an apps install order to say 99, the app disappears from the list...

  9. #9
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,415

    Re: Heavy form, need help to solve exceptions, many of....

    try it with this:

    Code:
    If ln.ToLower.StartsWith("install order") Then
        installOrder = CInt(ln.Substring(ln.IndexOf(":"c) + 1))
        highestIO = installOrder
    + this:

    Code:
    Dim cOrder As Integer = 0
    Do While (cOrder < (highestIO + 1))
        Try
    
            If Not programs.ContainsKey(cOrder) Then
                'TODO: Warning!!! continue If
                cOrder = (cOrder + 1)
                Continue Do
            End If
    **edited**

  10. #10
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,415

    Re: Heavy form, need help to solve exceptions, many of....

    see edit in post #9

  11. #11
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,415

    Re: Heavy form, need help to solve exceptions, many of....

    Code:
    If ln.ToLower.StartsWith("install order") Then
        installOrder = CInt(ln.Substring(ln.IndexOf(":"c) + 1))
        if installOrder > highestIO then highestIO = installOrder

  12. #12

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2013
    Posts
    336

    Re: Heavy form, need help to solve exceptions, many of....

    no luck with it........

  13. #13
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,415

    Re: Heavy form, need help to solve exceptions, many of....

    try using the code from post#11 + the 2nd code block from post#9
    I can't test your app for 2 reasons, first I've deleted it + second, I don't have the programs installed on my PC, but i'm sure that should do it...

  14. #14

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2013
    Posts
    336

    Re: Heavy form, need help to solve exceptions, many of....

    Yh, I have... Don't work, you can re-download it, link in post #4......

    Add some number items manually.

  15. #15
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,415

    Re: Heavy form, need help to solve exceptions, many of....

    post the full code you tried.
    as I said I can't test it as I don't have the files listed in the txt file. it just loads with an empty listview

  16. #16

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2013
    Posts
    336

    Re: Heavy form, need help to solve exceptions, many of....

    Code:
    Imports System
    Imports System.Collections.Generic
    Imports System.ComponentModel
    Imports System.Data
    Imports System.Drawing
    Imports System.Text
    Imports System.Windows.Forms
    Imports System.IO
    
    Public Class SelectPrograms
    
        'App Name              : Post Install
        'Author                : Chris Reynolds (Chris2k)
        'Creation Date         : 26th March 2013
        '
        'To do:
        '       Add a settings form.........
        '       Improve the editor..........
        '       Add update ability..........
        '       Add icons to app list.......
        '       Fix install order n force install ability....
        '       Add logfile..........................
    
    
        Public Shared Ver As String = " - Version 1.0.1 Beta 2"
        Public Shared programs As Dictionary(Of Integer, program) = New Dictionary(Of Integer, program)
    
        '//Hotkeys
        Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Long) As Integer
    
        Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
            Dim Hotkey_StopAutoStart As Boolean = GetAsyncKeyState(Keys.P)
            Dim Hotkey_ShowEditor As Boolean = GetAsyncKeyState(Keys.F1)
    
            If Hotkey_StopAutoStart = True Then
                CheckBox2.Checked = True
                Seconds_Remain.Enabled = False
                CheckBox2.Enabled = False
            End If
            If Hotkey_ShowEditor = True Then 'Show the editor "F1"
                Editor.Show()
                CheckBox2.Checked = True
                Seconds_Remain.Enabled = False
                CheckBox2.Enabled = False
            End If
        End Sub
    
        Dim autoStart As Integer = 41
    
        Private Sub SelectPrograms_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Me.Text = "Post Install By Chris2k" + Ver
    
            Dim iniFile As String = Application.StartupPath + "\Start\InstallCFG.ini"
    
            If Not (System.IO.File.Exists(iniFile)) Then
                MessageBox.Show("The programs opted for this OS can't be installed as the InstallCFG.ini has not been included...")
            End If
    
            Dim highestIO As Integer = 0
            Dim installOrder As Integer = 0
            For Each ln In IO.File.ReadAllLines(iniFile)
                If ln.StartsWith("#") Or ln.Trim = "" Then Continue For
                Try
                    If ln.ToLower.StartsWith("install order") Then
                        installOrder = CInt(ln.Substring(ln.IndexOf(":"c) + 1))
                        If installOrder > highestIO Then highestIO = installOrder
                        programs.Add(installOrder, New program)
                    ElseIf ln.ToLower.StartsWith("app name") Then
                        programs(installOrder).name = (ln.Substring(ln.IndexOf(":"c) + 1))
                    ElseIf ln.ToLower.StartsWith("description") Then
                        programs(installOrder).desc = (ln.Substring(ln.IndexOf(":"c) + 1))
                        '//ElseIf ln.ToLower.StartsWith("app file size") Then
                        '//programs(installOrder).filesize = getFileSize(program.exepath) (ln.Substring(ln.IndexOf(":"c) + 1))
                    ElseIf ln.ToLower.StartsWith("app file") Then
                        programs(installOrder).exepath = (ln.Substring(ln.IndexOf(":"c) + 1))
                        programs(installOrder).exeicon = getIcon(programs(installOrder).exepath)
                    End If
                Catch ex As Exception
    
                End Try
            Next
    
            Dim cOrder As Integer = 0
            Do While (cOrder < (highestIO + 1))
                Try
                    If Not programs.ContainsKey(cOrder) Then
                        cOrder = (cOrder + 1)
                        Continue Do
                    End If
    
                    Dim program As program = programs(cOrder)
                    If Not (program) Is Nothing AndAlso program.name.Length > 0 Then
                        If IO.File.Exists(program.exepath) Then
                            imageList1.Images.Add(program.name, program.exeicon.ToBitmap)
                            Dim pLI As ListViewItem = New ListViewItem(program.name, program.name)
                            pLI.SubItems.Add(program.desc)
                            pLI.SubItems.Add(getFileSize(program.exepath))
                            pLI.SubItems.Add(program.exepath)
                            pLI.Checked = True
                            App_List.Items.Add(pLI)
                        Else
                            '"Installer file for program '" + (program.name + "' could not be found!"
                        End If
                    Else
                        '"Failed to load program from order: " + (cOrder + "..!"
                    End If
    
    
                Catch ex As Exception
    
                Finally
                    cOrder = (cOrder + 1)
                End Try
            Loop
            Seconds_Remain.Start()
        End Sub
    
        Public Function getFileSize(ByVal path As String) As String
            Dim sizes() As String = New String() {"B", "KB", "MB", "GB"}
            Dim len = My.Computer.FileSystem.GetFileInfo(path).Length
            Dim order As Integer = 0
    
            While ((len >= 1024) _
                        AndAlso (order + (1 < sizes.Length)))
                order = (order + 1)
                len = (len / 1024)
    
            End While
            Return String.Format("{0:0.##} {1}", len, sizes(order))
        End Function
    
        Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged
            If CheckBox2.Checked = True Then
                Seconds_Remain.Enabled = False
                CheckBox2.Enabled = False
            End If
        End Sub
    
        Public Function getIcon(ByVal path As String) As Icon
            Try
                Return Icon.ExtractAssociatedIcon(path)
            Catch ex As System.Exception
                Return Nothing
            End Try
        End Function
    
        Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
            If CheckBox1.Checked Then
                For Each CheckedApp As ListViewItem In App_List.Items
                    CheckedApp.Checked = True
                Next
            Else
                For Each CheckedApp As ListViewItem In App_List.Items
                    CheckedApp.Checked = False
                Next
            End If
            Button1.Text = "Start installing (" + App_List.CheckedItems.Count.ToString + " apps.)"
        End Sub
    
        Private Sub Seconds_Remain_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Seconds_Remain.Tick
            If autoStart > 0 Then
                autoStart -= 1
                CheckBox2.Text = "Stop ticking (" + autoStart.ToString & " Secs Remaining!)"
            ElseIf autoStart = 0 Then
                CheckBox2.Enabled = False
                Label2.Text = "We're gonna install now..."
                InstallPrograms.Show()
                Me.Hide()
            End If
        End Sub
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            If App_List.CheckedItems.Count > 0 Then
                Me.Hide()
                InstallPrograms.Show() '//Load in the form and install checked apps.
            Else
                MessageBox.Show("Nothing selected to install!")
            End If
        End Sub
    
        Private Sub App_List_ItemChecked(ByVal sender As Object, ByVal e As System.Windows.Forms.ItemCheckedEventArgs) Handles App_List.ItemChecked
            Button1.Text = "Start installing (" + App_List.CheckedItems.Count.ToString + " apps.)"
        End Sub
    End Class
    
    Public Class program
    
        Public order As Integer = 0
        Public name As String = ""
        Public desc As String = ""
        Public exepath As String = ""
        Public filesize As Integer
        Public install As Boolean = True
        Public exeicon As Icon = Nothing
    End Class

  17. #17
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,415

    Re: Heavy form, need help to solve exceptions, many of....

    it seems in the do loop, the Continue Do completes the Finally code before looping.
    change this:

    Code:
    If Not programs.ContainsKey(cOrder) Then
        cOrder = (cOrder + 1)
        Continue Do
    End If
    to this:

    Code:
    If Not programs.ContainsKey(cOrder) Then
        Continue Do
    End If

  18. #18

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2013
    Posts
    336

    Re: Heavy form, need help to solve exceptions, many of....

    it's getting therre, now showing 23 of 24..........

  19. #19
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,415

    Re: Heavy form, need help to solve exceptions, many of....

    there's nothing obvious that I can see there.
    all you can do is step through your code line by line + eventually you'll find the error.

    just a guess, but are you sure all 24 files exist? that'd cause your error

  20. #20

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2013
    Posts
    336

    Re: Heavy form, need help to solve exceptions, many of....

    ok tyvm, i noticed 2 files are missing, that was the prob...

    now some more exceptions related to getIcon func, do u no a fix?

  21. #21
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,415

    Re: Heavy form, need help to solve exceptions, many of....

    i'm not sure what the problem is there.
    start a new thread for that question. this thread is cluttered.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width