Jump to content

System.InvalidOperationException

- - - - -

  • Please log in to reply
2 replies to this topic

#1
xXAlphaXx

xXAlphaXx

    Learning Programmer

  • Members
  • PipPipPip
  • 85 posts
I can't figure this one out for the life of me. I am trying to get some public variables working and when ever I set them under the public class declaration I can't get the program to run.

I can't open a form whenever I set these public variables but if I remove them and dim them inside a function their is no issue.


Heres the code:

 Private Sub btnAdd_Click(sender As System.Object, e As System.EventArgs) Handles btnAdd.Click
        AddPaitent.Show()
        ' error is caused by public variables?
    End Sub



<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class AddPaitent
    Inherits System.Windows.Forms.Form


    Public strPharm As String = Me.txtPharmacy.Text
    Public strDate As String
    Public strFN As String
    Public charMI As Char = Me.txtMI.Text
    Public strLN As String
    Public strRPhone As String
    Public strAPhone As String
    Public strAddress As String
    Public strCity As String
    Public strState As String
    Public strSSN As String
    Public strAllergies(Me.lstAllergies.Items.Count + 1) As String
    Public strDisabilities(Me.lstDisabilities.Items.Count + 1) As String
    Public strInsProv As String = Me.txtInsuProv.Text
    Public strInsNum As String = Me.txtInsNum.Text
    Public strPPhys As String = Me.txtPPhys.Text
    Public strSPhys As String = Me.txtSPhys.Text
    Public strCGC As String = Me.txtCGC.Text
    Public strCGCN As String = Me.txtCGCN.Text
    Public strCase As String = Me.txtCase.Text
    Public strPysInfo As String = Me.txtPhysInfo.Text
    Public strPaitInfo As String = Me.txtPaitInfo.Text


   'Form overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        Try
            If disposing AndAlso components IsNot Nothing Then
                components.Dispose()
            End If
        Finally
            MyBase.Dispose(disposing)
        End Try
    End Sub


    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer


    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        Me.lblPharmacy = New System.Windows.Forms.Label()
        Me.txtPharmacy = New System.Windows.Forms.TextBox()
        Me.lblDate = New System.Windows.Forms.Label()
        Me.txtDateM = New System.Windows.Forms.TextBox()
        Me.lblFN = New System.Windows.Forms.Label()
        Me.txtFN = New System.Windows.Forms.TextBox()
        Me.txtMI = New System.Windows.Forms.TextBox()
        Me.lblMI = New System.Windows.Forms.Label()
        Me.lblLN = New System.Windows.Forms.Label()
        Me.txtLN = New System.Windows.Forms.TextBox()
        Me.lblAddress = New System.Windows.Forms.Label()
        Me.txtAddress = New System.Windows.Forms.TextBox()
        Me.lblCity = New System.Windows.Forms.Label()
        Me.txtCity = New System.Windows.Forms.TextBox()
        Me.lblState = New System.Windows.Forms.Label()
        Me.txtState = New System.Windows.Forms.TextBox()
        Me.lblSSN = New System.Windows.Forms.Label()
        Me.txtSSN1 = New System.Windows.Forms.TextBox()
        Me.Label1 = New System.Windows.Forms.Label()
        Me.txtPhone1 = New System.Windows.Forms.TextBox()
        Me.lblAltPhone = New System.Windows.Forms.Label()
        Me.lblCGC = New System.Windows.Forms.Label()
        Me.txtCGC = New System.Windows.Forms.TextBox()
        Me.lblCGCN = New System.Windows.Forms.Label()
        Me.txtCGCN = New System.Windows.Forms.TextBox()
        Me.grpAllergies = New System.Windows.Forms.GroupBox()
        Me.radANO = New System.Windows.Forms.RadioButton()
        Me.radAYes = New System.Windows.Forms.RadioButton()
        Me.lstAllergies = New System.Windows.Forms.ListBox()
        Me.txtAllergies = New System.Windows.Forms.TextBox()
        Me.btnAdd = New System.Windows.Forms.Button()
        Me.btnARemove = New System.Windows.Forms.Button()
        Me.GroupBox2 = New System.Windows.Forms.GroupBox()
        Me.radDNo = New System.Windows.Forms.RadioButton()
        Me.radDYes = New System.Windows.Forms.RadioButton()
        Me.lstDisabilities = New System.Windows.Forms.ListBox()
        Me.txtDisabilities = New System.Windows.Forms.TextBox()
        Me.btnDAdd = New System.Windows.Forms.Button()
        Me.btnDRemove = New System.Windows.Forms.Button()
        Me.lblInsPro = New System.Windows.Forms.Label()
        Me.txtInsuProv = New System.Windows.Forms.TextBox()
        Me.lblInsNum = New System.Windows.Forms.Label()
        Me.txtInsNum = New System.Windows.Forms.TextBox()
        Me.lblPPhys = New System.Windows.Forms.Label()
        Me.txtPPhys = New System.Windows.Forms.TextBox()
        Me.lblSPhys = New System.Windows.Forms.Label()
        Me.txtSPhys = New System.Windows.Forms.TextBox()
        Me.lblCase = New System.Windows.Forms.Label()
        Me.txtCase = New System.Windows.Forms.TextBox()
        Me.txtPhysInfo = New System.Windows.Forms.TextBox()
        Me.lblPAddInfo = New System.Windows.Forms.Label()
        Me.lblPaitInfo = New System.Windows.Forms.Label()
        Me.txtPaitInfo = New System.Windows.Forms.TextBox()
        Me.btnCancel = New System.Windows.Forms.Button()
        Me.btnOK = New System.Windows.Forms.Button()
        Me.txtSSN2 = New System.Windows.Forms.TextBox()
        Me.txtSSN3 = New System.Windows.Forms.TextBox()
        Me.txtPhone2 = New System.Windows.Forms.TextBox()
        Me.txtPhone3 = New System.Windows.Forms.TextBox()
        Me.txtDateD = New System.Windows.Forms.TextBox()
        Me.txtDateY = New System.Windows.Forms.TextBox()
        Me.txtAPhone3 = New System.Windows.Forms.TextBox()
        Me.txtAPhone2 = New System.Windows.Forms.TextBox()
        Me.txtAPhone1 = New System.Windows.Forms.TextBox()
        Me.grpAllergies.SuspendLayout()
        Me.GroupBox2.SuspendLayout()
        Me.SuspendLayout()
        '
        'lblPharmacy
        '
        Me.lblPharmacy.AutoSize = True
        Me.lblPharmacy.Location = New System.Drawing.Point(12, 9)
        Me.lblPharmacy.Name = "lblPharmacy"
        Me.lblPharmacy.Size = New System.Drawing.Size(60, 13)
        Me.lblPharmacy.TabIndex = 0
        Me.lblPharmacy.Text = "Pharmacy: "
        '
        'txtPharmacy
        '
        Me.txtPharmacy.Location = New System.Drawing.Point(97, 9)
        Me.txtPharmacy.MaxLength = 128
        Me.txtPharmacy.Name = "txtPharmacy"
        Me.txtPharmacy.Size = New System.Drawing.Size(209, 20)
        Me.txtPharmacy.TabIndex = 1
        '
        'lblDate
        '
        Me.lblDate.AutoSize = True
        Me.lblDate.Location = New System.Drawing.Point(313, 12)
        Me.lblDate.Name = "lblDate"
        Me.lblDate.Size = New System.Drawing.Size(33, 13)
        Me.lblDate.TabIndex = 2
        Me.lblDate.Text = "Date:"
        '
        'txtDateM
        '
        Me.txtDateM.Location = New System.Drawing.Point(352, 9)
        Me.txtDateM.MaxLength = 2
        Me.txtDateM.Name = "txtDateM"
        Me.txtDateM.Size = New System.Drawing.Size(23, 20)
        Me.txtDateM.TabIndex = 2
        '
        'lblFN
        '
        Me.lblFN.AutoSize = True
        Me.lblFN.Location = New System.Drawing.Point(12, 38)
        Me.lblFN.Name = "lblFN"
        Me.lblFN.Size = New System.Drawing.Size(60, 13)
        Me.lblFN.TabIndex = 4
        Me.lblFN.Text = "Paitent FN:"
        '
        'txtFN
        '
        Me.txtFN.Location = New System.Drawing.Point(97, 35)
        Me.txtFN.MaxLength = 128
        Me.txtFN.Name = "txtFN"
        Me.txtFN.Size = New System.Drawing.Size(100, 20)
        Me.txtFN.TabIndex = 5
        '
        'txtMI
        '
        Me.txtMI.Location = New System.Drawing.Point(225, 35)
        Me.txtMI.MaxLength = 1
        Me.txtMI.Name = "txtMI"
        Me.txtMI.Size = New System.Drawing.Size(22, 20)
        Me.txtMI.TabIndex = 6
        '
        'lblMI
        '
        Me.lblMI.AutoSize = True
        Me.lblMI.Location = New System.Drawing.Point(200, 38)
        Me.lblMI.Name = "lblMI"
        Me.lblMI.Size = New System.Drawing.Size(22, 13)
        Me.lblMI.TabIndex = 7
        Me.lblMI.Text = "MI:"
        '
        'lblLN
        '
        Me.lblLN.AutoSize = True
        Me.lblLN.Location = New System.Drawing.Point(253, 38)
        Me.lblLN.Name = "lblLN"
        Me.lblLN.Size = New System.Drawing.Size(60, 13)
        Me.lblLN.TabIndex = 8
        Me.lblLN.Text = "Paitent LN:"
        '
        'txtLN
        '
        Me.txtLN.Location = New System.Drawing.Point(316, 35)
        Me.txtLN.MaxLength = 128
        Me.txtLN.Name = "txtLN"
        Me.txtLN.Size = New System.Drawing.Size(106, 20)
        Me.txtLN.TabIndex = 7
        '
        'lblAddress
        '
        Me.lblAddress.AutoSize = True
        Me.lblAddress.Location = New System.Drawing.Point(12, 64)
        Me.lblAddress.Name = "lblAddress"
        Me.lblAddress.Size = New System.Drawing.Size(48, 13)
        Me.lblAddress.TabIndex = 14
        Me.lblAddress.Text = "Address:"
        '
        'txtAddress
        '
        Me.txtAddress.Location = New System.Drawing.Point(97, 61)
        Me.txtAddress.MaxLength = 255
        Me.txtAddress.Name = "txtAddress"
        Me.txtAddress.Size = New System.Drawing.Size(213, 20)
        Me.txtAddress.TabIndex = 8
        '
        'lblCity
        '
        Me.lblCity.AutoSize = True
        Me.lblCity.Location = New System.Drawing.Point(313, 64)
        Me.lblCity.Name = "lblCity"
        Me.lblCity.Size = New System.Drawing.Size(27, 13)
        Me.lblCity.TabIndex = 16
        Me.lblCity.Text = "City:"
        '
        'txtCity
        '
        Me.txtCity.Location = New System.Drawing.Point(346, 61)
        Me.txtCity.MaxLength = 128
        Me.txtCity.Name = "txtCity"
        Me.txtCity.Size = New System.Drawing.Size(76, 20)
        Me.txtCity.TabIndex = 9
        '
        'lblState
        '
        Me.lblState.AutoSize = True
        Me.lblState.Location = New System.Drawing.Point(428, 64)
        Me.lblState.Name = "lblState"
        Me.lblState.Size = New System.Drawing.Size(35, 13)
        Me.lblState.TabIndex = 18
        Me.lblState.Text = "State:"
        '
        'txtState
        '
        Me.txtState.Location = New System.Drawing.Point(466, 61)
        Me.txtState.MaxLength = 2
        Me.txtState.Name = "txtState"
        Me.txtState.Size = New System.Drawing.Size(33, 20)
        Me.txtState.TabIndex = 10
        '
        'lblSSN
        '
        Me.lblSSN.AutoSize = True
        Me.lblSSN.Location = New System.Drawing.Point(431, 90)
        Me.lblSSN.Name = "lblSSN"
        Me.lblSSN.Size = New System.Drawing.Size(32, 13)
        Me.lblSSN.TabIndex = 20
        Me.lblSSN.Text = "SSN:"
        '
        'txtSSN1
        '
        Me.txtSSN1.Location = New System.Drawing.Point(466, 87)
        Me.txtSSN1.MaxLength = 3
        Me.txtSSN1.Name = "txtSSN1"
        Me.txtSSN1.Size = New System.Drawing.Size(33, 20)
        Me.txtSSN1.TabIndex = 17
        '
        'Label1
        '
        Me.Label1.AutoSize = True
        Me.Label1.Location = New System.Drawing.Point(12, 90)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(82, 13)
        Me.Label1.TabIndex = 22
        Me.Label1.Text = "Reliable Phone:"
        '
        'txtPhone1
        '
        Me.txtPhone1.Location = New System.Drawing.Point(97, 87)
        Me.txtPhone1.MaxLength = 3
        Me.txtPhone1.Name = "txtPhone1"
        Me.txtPhone1.Size = New System.Drawing.Size(31, 20)
        Me.txtPhone1.TabIndex = 11
        '
        'lblAltPhone
        '
        Me.lblAltPhone.AutoSize = True
        Me.lblAltPhone.Location = New System.Drawing.Point(227, 90)
        Me.lblAltPhone.Name = "lblAltPhone"
        Me.lblAltPhone.Size = New System.Drawing.Size(86, 13)
        Me.lblAltPhone.TabIndex = 24
        Me.lblAltPhone.Text = "Alternate Phone:"
        '
        'lblCGC
        '
        Me.lblCGC.AutoSize = True
        Me.lblCGC.Location = New System.Drawing.Point(346, 242)
        Me.lblCGC.Name = "lblCGC"
        Me.lblCGC.Size = New System.Drawing.Size(92, 13)
        Me.lblCGC.TabIndex = 26
        Me.lblCGC.Text = "Caregiver Contact"
        '
        'txtCGC
        '
        Me.txtCGC.Location = New System.Drawing.Point(381, 258)
        Me.txtCGC.MaxLength = 128
        Me.txtCGC.Name = "txtCGC"
        Me.txtCGC.Size = New System.Drawing.Size(100, 20)
        Me.txtCGC.TabIndex = 24
        '
        'lblCGCN
        '
        Me.lblCGCN.AutoSize = True
        Me.lblCGCN.Location = New System.Drawing.Point(346, 281)
        Me.lblCGCN.Name = "lblCGCN"
        Me.lblCGCN.Size = New System.Drawing.Size(132, 13)
        Me.lblCGCN.TabIndex = 28
        Me.lblCGCN.Text = "Caregiver Contact Number"
        '
        'txtCGCN
        '
        Me.txtCGCN.Location = New System.Drawing.Point(381, 298)
        Me.txtCGCN.MaxLength = 12
        Me.txtCGCN.Name = "txtCGCN"
        Me.txtCGCN.Size = New System.Drawing.Size(100, 20)
        Me.txtCGCN.TabIndex = 25
        '
        'grpAllergies
        '
        Me.grpAllergies.Controls.Add(Me.radANO)
        Me.grpAllergies.Controls.Add(Me.radAYes)
        Me.grpAllergies.Location = New System.Drawing.Point(15, 113)
        Me.grpAllergies.Name = "grpAllergies"
        Me.grpAllergies.Size = New System.Drawing.Size(100, 45)
        Me.grpAllergies.TabIndex = 30
        Me.grpAllergies.TabStop = False
        Me.grpAllergies.Text = "Allergies?"
        '
        'radANO
        '
        Me.radANO.AutoSize = True
        Me.radANO.Checked = True
        Me.radANO.Location = New System.Drawing.Point(57, 20)
        Me.radANO.Name = "radANO"
        Me.radANO.Size = New System.Drawing.Size(39, 17)
        Me.radANO.TabIndex = 19
        Me.radANO.TabStop = True
        Me.radANO.Text = "No"
        Me.radANO.UseVisualStyleBackColor = True
        '
        'radAYes
        '
        Me.radAYes.AutoSize = True
        Me.radAYes.Location = New System.Drawing.Point(7, 20)
        Me.radAYes.Name = "radAYes"
        Me.radAYes.Size = New System.Drawing.Size(43, 17)
        Me.radAYes.TabIndex = 18
        Me.radAYes.Text = "Yes"
        Me.radAYes.UseVisualStyleBackColor = True
        '
        'lstAllergies
        '
        Me.lstAllergies.FormattingEnabled = True
        Me.lstAllergies.Location = New System.Drawing.Point(123, 114)
        Me.lstAllergies.Name = "lstAllergies"
        Me.lstAllergies.Size = New System.Drawing.Size(120, 56)
        Me.lstAllergies.TabIndex = 31
        '
        'txtAllergies
        '
        Me.txtAllergies.Location = New System.Drawing.Point(123, 170)
        Me.txtAllergies.Name = "txtAllergies"
        Me.txtAllergies.Size = New System.Drawing.Size(120, 20)
        Me.txtAllergies.TabIndex = 20
        '
        'btnAdd
        '
        Me.btnAdd.Location = New System.Drawing.Point(123, 196)
        Me.btnAdd.Name = "btnAdd"
        Me.btnAdd.Size = New System.Drawing.Size(36, 23)
        Me.btnAdd.TabIndex = 33
        Me.btnAdd.Text = "Add"
        Me.btnAdd.UseVisualStyleBackColor = True
        '
        'btnARemove
        '
        Me.btnARemove.Location = New System.Drawing.Point(168, 196)
        Me.btnARemove.Name = "btnARemove"
        Me.btnARemove.Size = New System.Drawing.Size(75, 23)
        Me.btnARemove.TabIndex = 34
        Me.btnARemove.Text = "Remove"
        Me.btnARemove.UseVisualStyleBackColor = True
        '
        'GroupBox2
        '
        Me.GroupBox2.Controls.Add(Me.radDNo)
        Me.GroupBox2.Controls.Add(Me.radDYes)
        Me.GroupBox2.Location = New System.Drawing.Point(275, 113)
        Me.GroupBox2.Name = "GroupBox2"
        Me.GroupBox2.Size = New System.Drawing.Size(100, 45)
        Me.GroupBox2.TabIndex = 35
        Me.GroupBox2.TabStop = False
        Me.GroupBox2.Text = "Disabilities?"
        '
        'radDNo
        '
        Me.radDNo.AutoSize = True
        Me.radDNo.Checked = True
        Me.radDNo.Location = New System.Drawing.Point(52, 20)
        Me.radDNo.Name = "radDNo"
        Me.radDNo.Size = New System.Drawing.Size(39, 17)
        Me.radDNo.TabIndex = 1
        Me.radDNo.TabStop = True
        Me.radDNo.Text = "No"
        Me.radDNo.UseVisualStyleBackColor = True
        '
        'radDYes
        '
        Me.radDYes.AutoSize = True
        Me.radDYes.Location = New System.Drawing.Point(7, 20)
        Me.radDYes.Name = "radDYes"
        Me.radDYes.Size = New System.Drawing.Size(43, 17)
        Me.radDYes.TabIndex = 0
        Me.radDYes.Text = "Yes"
        Me.radDYes.UseVisualStyleBackColor = True
        '
        'lstDisabilities
        '
        Me.lstDisabilities.FormattingEnabled = True
        Me.lstDisabilities.Location = New System.Drawing.Point(395, 114)
        Me.lstDisabilities.Name = "lstDisabilities"
        Me.lstDisabilities.Size = New System.Drawing.Size(120, 56)
        Me.lstDisabilities.TabIndex = 36
        '
        'txtDisabilities
        '
        Me.txtDisabilities.Location = New System.Drawing.Point(395, 170)
        Me.txtDisabilities.Name = "txtDisabilities"
        Me.txtDisabilities.Size = New System.Drawing.Size(120, 20)
        Me.txtDisabilities.TabIndex = 37
        '
        'btnDAdd
        '
        Me.btnDAdd.Location = New System.Drawing.Point(395, 196)
        Me.btnDAdd.Name = "btnDAdd"
        Me.btnDAdd.Size = New System.Drawing.Size(36, 23)
        Me.btnDAdd.TabIndex = 38
        Me.btnDAdd.Text = "Add"
        Me.btnDAdd.UseVisualStyleBackColor = True
        '
        'btnDRemove
        '
        Me.btnDRemove.Location = New System.Drawing.Point(440, 196)
        Me.btnDRemove.Name = "btnDRemove"
        Me.btnDRemove.Size = New System.Drawing.Size(75, 23)
        Me.btnDRemove.TabIndex = 39
        Me.btnDRemove.Text = "Remove"
        Me.btnDRemove.UseVisualStyleBackColor = True
        '
        'lblInsPro
        '
        Me.lblInsPro.AutoSize = True
        Me.lblInsPro.Location = New System.Drawing.Point(12, 242)
        Me.lblInsPro.Name = "lblInsPro"
        Me.lblInsPro.Size = New System.Drawing.Size(96, 13)
        Me.lblInsPro.TabIndex = 40
        Me.lblInsPro.Text = "Insurance Provider"
        '
        'txtInsuProv
        '
        Me.txtInsuProv.Location = New System.Drawing.Point(47, 258)
        Me.txtInsuProv.MaxLength = 128
        Me.txtInsuProv.Name = "txtInsuProv"
        Me.txtInsuProv.Size = New System.Drawing.Size(100, 20)
        Me.txtInsuProv.TabIndex = 20
        '
        'lblInsNum
        '
        Me.lblInsNum.AutoSize = True
        Me.lblInsNum.Location = New System.Drawing.Point(12, 281)
        Me.lblInsNum.Name = "lblInsNum"
        Me.lblInsNum.Size = New System.Drawing.Size(75, 13)
        Me.lblInsNum.TabIndex = 42
        Me.lblInsNum.Text = "Policy Number"
        '
        'txtInsNum
        '
        Me.txtInsNum.Location = New System.Drawing.Point(48, 297)
        Me.txtInsNum.MaxLength = 128
        Me.txtInsNum.Name = "txtInsNum"
        Me.txtInsNum.Size = New System.Drawing.Size(100, 20)
        Me.txtInsNum.TabIndex = 21
        '
        'lblPPhys
        '
        Me.lblPPhys.AutoSize = True
        Me.lblPPhys.Location = New System.Drawing.Point(190, 242)
        Me.lblPPhys.Name = "lblPPhys"
        Me.lblPPhys.Size = New System.Drawing.Size(114, 13)
        Me.lblPPhys.TabIndex = 44
        Me.lblPPhys.Text = "Primary Care Physician"
        '
        'txtPPhys
        '
        Me.txtPPhys.Location = New System.Drawing.Point(225, 258)
        Me.txtPPhys.MaxLength = 128
        Me.txtPPhys.Name = "txtPPhys"
        Me.txtPPhys.Size = New System.Drawing.Size(100, 20)
        Me.txtPPhys.TabIndex = 22
        '
        'lblSPhys
        '
        Me.lblSPhys.AutoSize = True
        Me.lblSPhys.Location = New System.Drawing.Point(190, 281)
        Me.lblSPhys.Name = "lblSPhys"
        Me.lblSPhys.Size = New System.Drawing.Size(98, 13)
        Me.lblSPhys.TabIndex = 46
        Me.lblSPhys.Text = "Specialty Physician"
        '
        'txtSPhys
        '
        Me.txtSPhys.Location = New System.Drawing.Point(225, 296)
        Me.txtSPhys.MaxLength = 128
        Me.txtSPhys.Name = "txtSPhys"
        Me.txtSPhys.Size = New System.Drawing.Size(100, 20)
        Me.txtSPhys.TabIndex = 23
        '
        'lblCase
        '
        Me.lblCase.AutoSize = True
        Me.lblCase.Location = New System.Drawing.Point(351, 333)
        Me.lblCase.Name = "lblCase"
        Me.lblCase.Size = New System.Drawing.Size(76, 13)
        Me.lblCase.TabIndex = 48
        Me.lblCase.Text = "Case Manager"
        '
        'txtCase
        '
        Me.txtCase.Location = New System.Drawing.Point(381, 349)
        Me.txtCase.MaxLength = 128
        Me.txtCase.Name = "txtCase"
        Me.txtCase.Size = New System.Drawing.Size(100, 20)
        Me.txtCase.TabIndex = 26
        '
        'txtPhysInfo
        '
        Me.txtPhysInfo.Location = New System.Drawing.Point(40, 349)
        Me.txtPhysInfo.MaxLength = 255
        Me.txtPhysInfo.Multiline = True
        Me.txtPhysInfo.Name = "txtPhysInfo"
        Me.txtPhysInfo.Size = New System.Drawing.Size(285, 76)
        Me.txtPhysInfo.TabIndex = 27
        '
        'lblPAddInfo
        '
        Me.lblPAddInfo.AutoSize = True
        Me.lblPAddInfo.Location = New System.Drawing.Point(12, 333)
        Me.lblPAddInfo.Name = "lblPAddInfo"
        Me.lblPAddInfo.Size = New System.Drawing.Size(156, 13)
        Me.lblPAddInfo.TabIndex = 51
        Me.lblPAddInfo.Text = "Additional Physician Information"
        '
        'lblPaitInfo
        '
        Me.lblPaitInfo.AutoSize = True
        Me.lblPaitInfo.Location = New System.Drawing.Point(12, 445)
        Me.lblPaitInfo.Name = "lblPaitInfo"
        Me.lblPaitInfo.Size = New System.Drawing.Size(144, 13)
        Me.lblPaitInfo.TabIndex = 52
        Me.lblPaitInfo.Text = "Additional Paitent Information"
        '
        'txtPaitInfo
        '
        Me.txtPaitInfo.Location = New System.Drawing.Point(40, 470)
        Me.txtPaitInfo.MaxLength = 255
        Me.txtPaitInfo.Multiline = True
        Me.txtPaitInfo.Name = "txtPaitInfo"
        Me.txtPaitInfo.Size = New System.Drawing.Size(532, 76)
        Me.txtPaitInfo.TabIndex = 28
        '
        'btnCancel
        '
        Me.btnCancel.Location = New System.Drawing.Point(497, 557)
        Me.btnCancel.Name = "btnCancel"
        Me.btnCancel.Size = New System.Drawing.Size(75, 23)
        Me.btnCancel.TabIndex = 30
        Me.btnCancel.Text = "Cancel"
        Me.btnCancel.UseVisualStyleBackColor = True
        '
        'btnOK
        '
        Me.btnOK.Location = New System.Drawing.Point(416, 557)
        Me.btnOK.Name = "btnOK"
        Me.btnOK.Size = New System.Drawing.Size(75, 23)
        Me.btnOK.TabIndex = 29
        Me.btnOK.Text = "Ok"
        Me.btnOK.UseVisualStyleBackColor = True
        '
        'txtSSN2
        '
        Me.txtSSN2.Location = New System.Drawing.Point(502, 87)
        Me.txtSSN2.MaxLength = 2
        Me.txtSSN2.Name = "txtSSN2"
        Me.txtSSN2.Size = New System.Drawing.Size(21, 20)
        Me.txtSSN2.TabIndex = 18
        '
        'txtSSN3
        '
        Me.txtSSN3.Location = New System.Drawing.Point(526, 87)
        Me.txtSSN3.MaxLength = 4
        Me.txtSSN3.Name = "txtSSN3"
        Me.txtSSN3.Size = New System.Drawing.Size(46, 20)
        Me.txtSSN3.TabIndex = 19
        '
        'txtPhone2
        '
        Me.txtPhone2.Location = New System.Drawing.Point(131, 87)
        Me.txtPhone2.MaxLength = 3
        Me.txtPhone2.Name = "txtPhone2"
        Me.txtPhone2.Size = New System.Drawing.Size(31, 20)
        Me.txtPhone2.TabIndex = 12
        '
        'txtPhone3
        '
        Me.txtPhone3.Location = New System.Drawing.Point(165, 87)
        Me.txtPhone3.MaxLength = 4
        Me.txtPhone3.Name = "txtPhone3"
        Me.txtPhone3.Size = New System.Drawing.Size(39, 20)
        Me.txtPhone3.TabIndex = 13
        '
        'txtDateD
        '
        Me.txtDateD.Location = New System.Drawing.Point(378, 9)
        Me.txtDateD.MaxLength = 2
        Me.txtDateD.Name = "txtDateD"
        Me.txtDateD.Size = New System.Drawing.Size(23, 20)
        Me.txtDateD.TabIndex = 3
        '
        'txtDateY
        '
        Me.txtDateY.Location = New System.Drawing.Point(404, 9)
        Me.txtDateY.MaxLength = 4
        Me.txtDateY.Name = "txtDateY"
        Me.txtDateY.Size = New System.Drawing.Size(50, 20)
        Me.txtDateY.TabIndex = 4
        '
        'txtAPhone3
        '
        Me.txtAPhone3.Location = New System.Drawing.Point(384, 87)
        Me.txtAPhone3.MaxLength = 4
        Me.txtAPhone3.Name = "txtAPhone3"
        Me.txtAPhone3.Size = New System.Drawing.Size(39, 20)
        Me.txtAPhone3.TabIndex = 16
        '
        'txtAPhone2
        '
        Me.txtAPhone2.Location = New System.Drawing.Point(350, 87)
        Me.txtAPhone2.MaxLength = 3
        Me.txtAPhone2.Name = "txtAPhone2"
        Me.txtAPhone2.Size = New System.Drawing.Size(31, 20)
        Me.txtAPhone2.TabIndex = 15
        '
        'txtAPhone1
        '
        Me.txtAPhone1.Location = New System.Drawing.Point(316, 87)
        Me.txtAPhone1.MaxLength = 3
        Me.txtAPhone1.Name = "txtAPhone1"
        Me.txtAPhone1.Size = New System.Drawing.Size(31, 20)
        Me.txtAPhone1.TabIndex = 14
        '
        'AddPaitent
        '
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.ClientSize = New System.Drawing.Size(594, 592)
        Me.Controls.Add(Me.txtAPhone3)
        Me.Controls.Add(Me.txtAPhone2)
        Me.Controls.Add(Me.txtAPhone1)
        Me.Controls.Add(Me.txtDateY)
        Me.Controls.Add(Me.txtDateD)
        Me.Controls.Add(Me.txtPhone3)
        Me.Controls.Add(Me.txtPhone2)
        Me.Controls.Add(Me.txtSSN3)
        Me.Controls.Add(Me.txtSSN2)
        Me.Controls.Add(Me.btnOK)
        Me.Controls.Add(Me.btnCancel)
        Me.Controls.Add(Me.txtPaitInfo)
        Me.Controls.Add(Me.lblPaitInfo)
        Me.Controls.Add(Me.lblPAddInfo)
        Me.Controls.Add(Me.txtPhysInfo)
        Me.Controls.Add(Me.txtCase)
        Me.Controls.Add(Me.lblCase)
        Me.Controls.Add(Me.txtSPhys)
        Me.Controls.Add(Me.lblSPhys)
        Me.Controls.Add(Me.txtPPhys)
        Me.Controls.Add(Me.lblPPhys)
        Me.Controls.Add(Me.txtInsNum)
        Me.Controls.Add(Me.lblInsNum)
        Me.Controls.Add(Me.txtInsuProv)
        Me.Controls.Add(Me.lblInsPro)
        Me.Controls.Add(Me.btnDRemove)
        Me.Controls.Add(Me.btnDAdd)
        Me.Controls.Add(Me.txtDisabilities)
        Me.Controls.Add(Me.lstDisabilities)
        Me.Controls.Add(Me.GroupBox2)
        Me.Controls.Add(Me.btnARemove)
        Me.Controls.Add(Me.btnAdd)
        Me.Controls.Add(Me.txtAllergies)
        Me.Controls.Add(Me.lstAllergies)
        Me.Controls.Add(Me.grpAllergies)
        Me.Controls.Add(Me.txtCGCN)
        Me.Controls.Add(Me.lblCGCN)
        Me.Controls.Add(Me.txtCGC)
        Me.Controls.Add(Me.lblCGC)
        Me.Controls.Add(Me.lblAltPhone)
        Me.Controls.Add(Me.txtPhone1)
        Me.Controls.Add(Me.Label1)
        Me.Controls.Add(Me.txtSSN1)
        Me.Controls.Add(Me.lblSSN)
        Me.Controls.Add(Me.txtState)
        Me.Controls.Add(Me.lblState)
        Me.Controls.Add(Me.txtCity)
        Me.Controls.Add(Me.lblCity)
        Me.Controls.Add(Me.txtAddress)
        Me.Controls.Add(Me.lblAddress)
        Me.Controls.Add(Me.txtLN)
        Me.Controls.Add(Me.lblLN)
        Me.Controls.Add(Me.lblMI)
        Me.Controls.Add(Me.txtMI)
        Me.Controls.Add(Me.txtFN)
        Me.Controls.Add(Me.lblFN)
        Me.Controls.Add(Me.txtDateM)
        Me.Controls.Add(Me.lblDate)
        Me.Controls.Add(Me.txtPharmacy)
        Me.Controls.Add(Me.lblPharmacy)
        Me.Name = "AddPaitent"
        Me.Text = "AddPaitent"
        Me.grpAllergies.ResumeLayout(False)
        Me.grpAllergies.PerformLayout()
        Me.GroupBox2.ResumeLayout(False)
        Me.GroupBox2.PerformLayout()
        Me.ResumeLayout(False)
        Me.PerformLayout()


    End Sub












    Friend WithEvents lblPharmacy As System.Windows.Forms.Label
    Friend WithEvents txtPharmacy As System.Windows.Forms.TextBox
    Friend WithEvents lblDate As System.Windows.Forms.Label
    Friend WithEvents txtDateM As System.Windows.Forms.TextBox
    Friend WithEvents lblFN As System.Windows.Forms.Label
    Friend WithEvents txtFN As System.Windows.Forms.TextBox
    Friend WithEvents txtMI As System.Windows.Forms.TextBox
    Friend WithEvents lblMI As System.Windows.Forms.Label
    Friend WithEvents lblLN As System.Windows.Forms.Label
    Friend WithEvents txtLN As System.Windows.Forms.TextBox
    Friend WithEvents lblAddress As System.Windows.Forms.Label
    Friend WithEvents txtAddress As System.Windows.Forms.TextBox
    Friend WithEvents lblCity As System.Windows.Forms.Label
    Friend WithEvents txtCity As System.Windows.Forms.TextBox
    Friend WithEvents lblState As System.Windows.Forms.Label
    Friend WithEvents txtState As System.Windows.Forms.TextBox
    Friend WithEvents lblSSN As System.Windows.Forms.Label
    Friend WithEvents txtSSN1 As System.Windows.Forms.TextBox
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents txtPhone1 As System.Windows.Forms.TextBox
    Friend WithEvents lblAltPhone As System.Windows.Forms.Label
    Friend WithEvents lblCGC As System.Windows.Forms.Label
    Friend WithEvents txtCGC As System.Windows.Forms.TextBox
    Friend WithEvents lblCGCN As System.Windows.Forms.Label
    Friend WithEvents txtCGCN As System.Windows.Forms.TextBox
    Friend WithEvents grpAllergies As System.Windows.Forms.GroupBox
    Friend WithEvents radANO As System.Windows.Forms.RadioButton
    Friend WithEvents radAYes As System.Windows.Forms.RadioButton
    Friend WithEvents lstAllergies As System.Windows.Forms.ListBox
    Friend WithEvents txtAllergies As System.Windows.Forms.TextBox
    Friend WithEvents btnAdd As System.Windows.Forms.Button
    Friend WithEvents btnARemove As System.Windows.Forms.Button
    Friend WithEvents GroupBox2 As System.Windows.Forms.GroupBox
    Friend WithEvents radDNo As System.Windows.Forms.RadioButton
    Friend WithEvents radDYes As System.Windows.Forms.RadioButton
    Friend WithEvents lstDisabilities As System.Windows.Forms.ListBox
    Friend WithEvents txtDisabilities As System.Windows.Forms.TextBox
    Friend WithEvents btnDAdd As System.Windows.Forms.Button
    Friend WithEvents btnDRemove As System.Windows.Forms.Button
    Friend WithEvents lblInsPro As System.Windows.Forms.Label
    Friend WithEvents txtInsuProv As System.Windows.Forms.TextBox
    Friend WithEvents lblInsNum As System.Windows.Forms.Label
    Friend WithEvents txtInsNum As System.Windows.Forms.TextBox
    Friend WithEvents lblPPhys As System.Windows.Forms.Label
    Friend WithEvents txtPPhys As System.Windows.Forms.TextBox
    Friend WithEvents lblSPhys As System.Windows.Forms.Label
    Friend WithEvents txtSPhys As System.Windows.Forms.TextBox
    Friend WithEvents lblCase As System.Windows.Forms.Label
    Friend WithEvents txtCase As System.Windows.Forms.TextBox
    Friend WithEvents txtPhysInfo As System.Windows.Forms.TextBox
    Friend WithEvents lblPAddInfo As System.Windows.Forms.Label
    Friend WithEvents lblPaitInfo As System.Windows.Forms.Label
    Friend WithEvents txtPaitInfo As System.Windows.Forms.TextBox
    Friend WithEvents btnCancel As System.Windows.Forms.Button
    Friend WithEvents btnOK As System.Windows.Forms.Button
    Friend WithEvents txtSSN2 As System.Windows.Forms.TextBox
    Friend WithEvents txtSSN3 As System.Windows.Forms.TextBox
    Friend WithEvents txtPhone2 As System.Windows.Forms.TextBox
    Friend WithEvents txtPhone3 As System.Windows.Forms.TextBox
    Friend WithEvents txtDateD As System.Windows.Forms.TextBox
    Friend WithEvents txtDateY As System.Windows.Forms.TextBox
    Friend WithEvents txtAPhone3 As System.Windows.Forms.TextBox
    Friend WithEvents txtAPhone2 As System.Windows.Forms.TextBox
    Friend WithEvents txtAPhone1 As System.Windows.Forms.TextBox


'my subs start here




I will no longer open the form when it gets called from the previous form. Any ideas why?

An unhandled exception of type 'System.InvalidOperationException' occurred in Program.exe


Additional information: An error occurred creating the form. See Exception.InnerException for details.  The error is: Object reference not set to an instance of an object.


#2
lespauled

lespauled

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 232 posts
  • Programming Language:C, C++, C#, JavaScript, PL/SQL, Delphi/Object Pascal, Visual Basic .NET, Pascal, Transact-SQL, Bash
So, the button's Add_Click event is in another form, correct?

#3
Blimp

Blimp

    Programmer

  • Members
  • PipPipPipPip
  • 154 posts
Not sure if this is on the right track here, but it could be something to do with:

CheckForIllegalCrossThreadCalls = False





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users