Form2.Show上的VB NullReferenceException和InvalidOperationException?

时间:2014-01-29 10:36:56

标签: vb.net exception null dotnetbar

打开第二张表格后,我收到两个错误,我无法找到解决办法。错误是:

System.NullReferenceException& System.InvalidOperationException

是否有任何与Form2.Show()冲突的代码?有没有办法来解决这个问题?也许是DotNetBar?

    Option Explicit On

'Imports NAudio
Imports System.Net

Public Class Form1

    Dim SoundName As String
    'Dim Is64Bit As Boolean
    Dim mainDrive As String = Mid(Environment.GetFolderPath(Environment.SpecialFolder.System), 1, 3)
    Dim WithEvents WC As New WebClient

    Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Integer, ByVal hwndCallback As Integer) As Integer

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'If Form2.SwitchButton1.Value = True Then
        'updateTimer.Start()
        'End If

        'Is64Bit = Not String.IsNullOrEmpty(Environment.GetEnvironmentVariable("PROCESSOR_ARCHITEW6432"))
        Me.Height = 560
        MsgBox("Copyright © 2014 Johnathon Matczak - Do Not Distribute. Exclusive Indev (Pre-Alpha) Release.")
    End Sub

    Private Sub GlobalMute(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SwitchButton5.ValueChanged
        If SwitchButton5.Value = True Then
            SwitchButton1.Enabled = False
            SwitchButton2.Enabled = False
            SwitchButton3.Enabled = False
            SwitchButton4.Enabled = False

            SwitchButton1.Value = False
            SwitchButton2.Value = False
            SwitchButton3.Value = False
            SwitchButton4.Value = False
        Else
            SwitchButton1.Enabled = True
            SwitchButton2.Enabled = True
            SwitchButton3.Enabled = True
            SwitchButton4.Enabled = True
        End If
    End Sub

    Private Sub ButtonX9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonX9.Click
        ContextMenuStrip1.Show(Me, cmsLocation.Location, ToolStripDropDownDirection.BelowRight)
    End Sub

    Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click

        End 'Exit
    End Sub

    Private Sub displayWarning()
        Me.Height = 560
    End Sub

    '==============================ERROR v===============================

    Private Sub WarningBox1_OptionsClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles WarningBox1.OptionsClick
        If WarningBox1.OptionsText = "Update" Then
            Try
                Form3.Show()
            Catch ex As Exception
                MsgBox("Error upon opening: Update.")
            End Try
        ElseIf WarningBox1.OptionsText = "Options" Then
            Try
                Form2.Show()
            Catch ex As Exception
                MsgBox("Error upon opening: Options.")
            End Try

        End If
    End Sub

    '==============================ERROR ^===============================

    Private Sub WarningBox1_CloseClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles WarningBox1.CloseClick
        Me.Height = 522

        WarningBox1.Visible = False
    End Sub

    Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles updateTimer.Tick
        Try
            WC.DownloadFileAsync(New Uri("https://dl.dropboxusercontent.com/s/m4yc0q0p6tfifbc/update.txt?dl=1&token_hash=AAG_35IFFk_O-4j6gJDQHrScMnitm9Fm9fhOfH68EKEGcA"), mainDrive + "Program Files\Matczak Software\Uber DJ\update.txt")
        Catch ex As Exception
            MsgBox("Unable to check for updates! Please make sure you are connected to the internet!")
        End Try

        Dim fileReader As String
        fileReader = My.Computer.FileSystem.ReadAllText(mainDrive + "Program Files\Matczak Software\Uber DJ\update.txt")
        MsgBox(fileReader)

        If fileReader = "1" Then
            WarningBox1.Visible = True
            Me.Height = 560

            WarningBox1.OptionsText = "Update"
            WarningBox1.Text = "<b>Update Avaliable!</b> There is an update avaliable! Click <i>Update</i>  to update Uber DJ."
        Else

        End If

    End Sub

    Private Sub CheckBoxX2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxX2.CheckedChanged
        If CheckBoxX2.Checked = True Then
            'Listen to mic
        Else
            'Turn off listen
        End If
    End Sub
End Class

0 个答案:

没有答案