CODE:
Private ingredientProperties(,) As Integer = {{ingredient1.Location.X, ingredient1.Location.Y}, {ingredient1.Size.Width, ingredient1.Size.Height}} ' {{ingredient location X, Y}, {ingredient size X, Y}}
Private amountProperties(,) As Integer = {{amount1.Location.X, amount1.Location.Y}, {amount1.Size.Width, amount1.Size.Height}} ' {{amount location X, Y}, {amount size X, Y}}
Here I am declaring two 2-d array's in the class scope that contain the locations and sizes of two text boxes. I am pretty sure I am getting this error:
An unhandled exception of type 'System.InvalidOperationException' occurred in Recipe Manager.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.
because the location and sizes are not existant yet, are there any alternate ways to declare them?
Private ingredientProperties(,) As Integerin your class and then doingredientProperties = {{ingredient1.Location.X, ingredient1.Location.Y}, {ingredient1.Size.Width, ingredient1.Size.Height}}in yourForm_Loadthe variable is initialized and it can be accessed like you want it.