|
-
Mar 28th, 2004, 12:26 AM
#1
Thread Starter
PowerPoster
-
Mar 28th, 2004, 02:21 AM
#2
VB Code:
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
MyVar = Color.Red
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
[B]'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.[/B]
Friend WithEvents Button1 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Button1 = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(152, 144)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(64, 24)
Me.Button1.TabIndex = 0
Me.Button1.Text = "asdas"
Me.Button1.BackColor = MyVar
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 266)
Me.Controls.Add(Me.Button1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
#End Region
Why do you need to do it this way? just Do what you need to do in the forms Constructor.
My guess is the the error is a flaw, or something that wasnt expected my the forms designer because it says explicitly not to change any of the code/
Tips:
- Google is your friend! Search before posting!
- Name your thread appropriately... "I Need Help" doesn't cut it!
- Always post your code!!!! We can't read your mind!!! (well, at least most of us!)
- Allways Include the Name and Line of the Exception (if one is occuring!)
- If it is relevant state the version of Visual Studio/.Net Framwork you are using (2002/2003/2005)
If you think I was helpful, rate my post  IRC Contact: Rizon/xous ChakraNET/xous Freenode/xous
-
Mar 28th, 2004, 03:37 AM
#3
It's probably because you have your code BEFORE the InitializeComponent call. See the comment below that call:
'Add any initialization after the InitializeComponent() call
See if this gets rid of the error:
VB Code:
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
MyVar = Color.Red
End Sub
-
Mar 28th, 2004, 05:53 AM
#4
Thread Starter
PowerPoster
Originally posted by Edneeis
It's probably because you have your code BEFORE the InitializeComponent call. See the comment below that call:
'Add any initialization after the InitializeComponent() call
See if this gets rid of the error:
VB Code:
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
MyVar = Color.Red
End Sub
This seems to have solved the problem. 
And I have no idea why we have to do it like this... it really could be done in form load, but apparently the head of the course is abit of a dick.
-
Mar 28th, 2004, 01:09 PM
#5
It makes sense that it is in the constructor which gets called when the form gets created.
-
Mar 28th, 2004, 04:59 PM
#6
PowerPoster
"And I have no idea why we have to do it like this... it really could be done in form load, but apparently the head of the course is abit of a dick. "
or perhaps your instructor thinks this is the best way to get you to learn what you have learned
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|