Click here to Skip to main content
15,920,111 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: deploying .net apps with nsis Pin
fire.fox4-Feb-05 22:09
fire.fox4-Feb-05 22:09 
Generalbuild problem Pin
Ajek3-Feb-05 0:15
Ajek3-Feb-05 0:15 
GeneralDeploying Assemblys to the GAC Pin
JohnARyan2-Feb-05 6:46
JohnARyan2-Feb-05 6:46 
GeneralRe: Deploying Assemblys to the GAC Pin
Charlie Williams3-Feb-05 12:40
Charlie Williams3-Feb-05 12:40 
GeneralEncryption keys Pin
Ray Cassick1-Feb-05 18:41
Ray Cassick1-Feb-05 18:41 
GeneralRe: Encryption keys Pin
Robert Rohde1-Feb-05 21:42
Robert Rohde1-Feb-05 21:42 
GeneralRe: Encryption keys Pin
S. Senthil Kumar8-Feb-05 10:23
S. Senthil Kumar8-Feb-05 10:23 
Questionwhere did InstMsiW.Exe and InstMsiA.Exe go? Pin
Galen_21-Feb-05 12:22
Galen_21-Feb-05 12:22 
AnswerRe: where did InstMsiW.Exe and InstMsiA.Exe go? Pin
rwestgraham1-Feb-05 20:27
rwestgraham1-Feb-05 20:27 
Generalsubject : programming with .NET Framework to browsing my bank account, buy and sell stock shares Pin
Close Network1-Feb-05 5:47
Close Network1-Feb-05 5:47 
GeneralRemoting channels Pin
neeru26197631-Jan-05 22:33
neeru26197631-Jan-05 22:33 
GeneralRe: Remoting channels Pin
Charlie Williams1-Feb-05 4:51
Charlie Williams1-Feb-05 4:51 
GeneralInstaller woes Pin
Arun Bhalla31-Jan-05 19:29
Arun Bhalla31-Jan-05 19:29 
GeneralRe: Installer woes Pin
rwestgraham1-Feb-05 15:27
rwestgraham1-Feb-05 15:27 
GeneralRe: Installer woes Pin
Arun Bhalla2-Feb-05 8:46
Arun Bhalla2-Feb-05 8:46 
GeneralRe: Installer woes Pin
Arun Bhalla2-Feb-05 9:27
Arun Bhalla2-Feb-05 9:27 
GeneralRe: Installer woes Pin
rwestgraham2-Feb-05 11:57
rwestgraham2-Feb-05 11:57 
GeneralRe: Installer woes Pin
Arun Bhalla2-Feb-05 13:13
Arun Bhalla2-Feb-05 13:13 
GeneralRe: Installer woes Pin
rwestgraham2-Feb-05 13:29
rwestgraham2-Feb-05 13:29 
GeneralRe: Installer woes Pin
Arun Bhalla2-Feb-05 13:37
Arun Bhalla2-Feb-05 13:37 
Generalmy.msn.com Style Web Page Pin
Khurram Raza31-Jan-05 18:50
Khurram Raza31-Jan-05 18:50 
QuestionHow do I execute a class from a class? Pin
DSLR30-Jan-05 12:52
DSLR30-Jan-05 12:52 
Hello to all.

I know how to program but I am not that good in .NET

In my main form (form1) I create 2 arrays within a panel. One with buttons and textboxes and the other array with labels who give the state of the 1ste array.
This is created by executing class1 and class2

The problem is that when I click on a button in panel1 (array1) then the state of that button, tagged textbox and my global variable (class global) change but, I want to change the label in panel2 (array2) to but that generates an error when I click on it and I don’t know how to interpret that error or what to do with it.
Properly my bad English or lake of .NET knowledge.

Can somebody help me?

The error is ‘An unhandled exception of type 'System.NullReferenceException' occurred in test.exe
Additional information: Object reference not set to an instance of an object.’

<code>public Class Form1
Inherits System.Windows.Forms.Form
Dim MyArray1 As Array1
Dim MyArray2 As Array2
Dim Filibits As Integer

Public Sub New()
MyBase.New()

InitializeComponent()

MyArray1 = New Array1(Me.Panel1)
MyArray1.AddNewFilibitControl(7, 19)

MyArray2 = New Array2(Me.Panel2)
MyArray2.AddNewStatusControl(7, 19)
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

Skiped the ‘Required by the Windows Form Designer’ and other not needed functions for this matter

End Class</code>

<code>Option Strict Off

Public Class Array1

Inherits System.Collections.CollectionBase
Private ReadOnly Host1 As System.Windows.Forms.Panel

Public BtnColorOn, BtnColorOff, BtnColorNA, BtnColorF, BtnColorT As System.Drawing.Color

Public Function AddNewGlobal(ByVal Index As Integer, ByVal Used As Integer)
Dim aTextBox As New System.Windows.Forms.TextBox
Me.List.Add(aTextBox)
Host1.Controls.Add(aTextBox)
aTextBox.MaxLength = 16
aTextBox.Height = 20
aTextBox.Width = 90
aTextBox.Left = 90 * (Index Mod 2) + (42 * (Index Mod 2))
aTextBox.Top = (30 * (Index \ 2)) + 2
Global.SetData(1, Index) = "Locatie # " & CStr(Index + 1)
Global.SetData(0, Index) = CStr(CInt(True))
aTextBox.Text = Microsoft.VisualBasic.Left(Global.GetData(1, Index), 16)
If Used < Index Then
aTextBox.Enabled = False
Else
aTextBox.Enabled = True
End If
aTextBox.Tag = Index
AddHandler aTextBox.TextChanged, AddressOf WhenTextChanged


Dim aButton As New System.Windows.Forms.Button
Me.List.Add(aButton)
Host1.Controls.Add(aButton)
aButton.Height = 24
aButton.Width = 40
aButton.Left = 90 * (Index Mod 2) + 90 + (42 * (Index Mod 2))
aButton.Top = (30 * (Index \ 2))
aButton.TextAlign = ContentAlignment.MiddleCenter
aButton.Name = "Button"
If Used < Index Then
aButton.Enabled = False
aButton.BackColor = BtnColorNA
aButton.Text = "N/A"
Else
aButton.Text = "ON"
aButton.BackColor = BtnColorOn
aButton.Enabled = True
End If
aButton.Tag = aTextBox
AddHandler aButton.Click, AddressOf OnOff_ClickHandler

End Function


Public Function AddNewFilibitControl(ByVal Used As Integer, ByVal Total As Integer) As Boolean
Dim Counter As Integer
For Counter = 0 To Total
Me.AddNewGlobal(Counter, Used)
Next
End Function

Public Sub New(ByVal host As System.Windows.Forms.Panel)
Host1 = host
BtnColorOn = System.Drawing.Color.Green
BtnColorOff = System.Drawing.Color.Yellow
BtnColorNA = System.Drawing.SystemColors.Control
End Sub


Public Sub OnOff_ClickHandler(ByVal sender As Object, ByVal e As System.EventArgs)
Dim MyArray2 As Array2

Dim IndexArray As Integer = CType(Host1.Controls.IndexOf(CType(sender, System.Windows.Forms.Button).Tag), Integer)
If TypeOf sender Is Button Then
' Create a button object to use in its place
Dim myButton As Button = CType(sender, System.Windows.Forms.Button)
' Check to see if the Button has a TextBox in its Tag property
If TypeOf myButton.Tag Is TextBox Then
CType(myButton.Tag, TextBox).Enabled = Not CType(myButton.Tag, TextBox).Enabled
Global.SetData(0, Int(IndexArray / 2)) = CStr(CInt(CType(myButton.Tag, TextBox).Enabled))
If True Then
If CType(myButton.Tag, TextBox).Enabled Then
CType(myButton, Button).Text = "ON"
CType(myButton, Button).BackColor = BtnColorOn

Else
CType(myButton, Button).Text = "OFF"
CType(myButton, Button).BackColor = BtnColorOff
MyArray2.Off(5) ‘<<<<< ERROR LINE >>>>>
End If
End If
Global.SetData(0, Int(IndexArray / 2)) = CStr(CInt(CType(myButton.Tag, TextBox).Enabled))
End If
End If
End Sub

Private Sub WhenTextChanged(ByVal sender As Object, ByVal e As EventArgs)
Dim myTextBox As TextBox = CType(sender, TextBox)
Dim RelIndex As Integer = CType(CType(sender, System.Windows.Forms.TextBox).Tag, Integer)
Global.SetData(1, RelIndex) = myTextBox.Text
End Sub
End Class</code>

<code>Option Strict Off

Public Class Array2

Inherits System.Collections.CollectionBase
Private ReadOnly Host2 As System.Windows.Forms.Panel

Public BtnColorOn, BtnColorOff, BtnColorNA As System.Drawing.Color

Public Function AddNewLabelTransponderStatus(ByVal Index As Integer, ByVal Used As Integer) As System.Windows.Forms.Label
Dim aLabel As New System.Windows.Forms.Label
' Add a Label to the collection's internal list.
Me.List.Add(aLabel)
' Add the button to the controls collection of the form
' referenced by the HostForm field.
Host2.Controls.Add(aLabel)
' Set intial properties for the button object.
aLabel.Height = 24
aLabel.Width = 40
aLabel.Left = 90 * (Index Mod 2) + (42 * (Index Mod 2))
aLabel.Top = (30 * (Index \ 2))
aLabel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
aLabel.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
aLabel.TextAlign = ContentAlignment.MiddleCenter
aLabel.Name = "Label"
aLabel.Tag = Index
If Used < Index Then
aLabel.BackColor = BtnColorNA
aLabel.Text = "NIC"
Else
aLabel.Text = "ON"
aLabel.BackColor = BtnColorOn
End If
End Function

Public Function AddNewStatusControl(ByVal Used As Integer, ByVal Total As Integer) As Boolean
Dim Counter As Integer
For Counter = 0 To Total
Me.AddNewLabelTransponderStatus(Counter, Used)
Next
End Function

Public Function Off(ByVal IndexArray As Integer)
Me.Host2.Controls(IndexArray).Enabled = False
End Function


Public Sub New(ByVal Host As System.Windows.Forms.Panel)
Host2 = Host
BtnColorOn = System.Drawing.Color.Green
BtnColorOff = System.Drawing.Color.Yellow
BtnColorNA = System.Drawing.SystemColors.Control
End Sub

Default Public ReadOnly Property Item(ByVal Index As Integer)
Get
If Me.List.Item(Index).GetType.Name = "TextBox" Then
Return CType(Me.List.Item(Index), System.Windows.Forms.TextBox)
ElseIf Me.List.Item(Index).GetType.Name = "Button" Then
Return CType(Me.List.Item(Index), System.Windows.Forms.Button)
ElseIf Me.List.Item(Index).GetType.Name = "Label" Then
Return CType(Me.List.Item(Index), System.Windows.Forms.Label)
End If
End Get
End Property

End Class</code>



Marco
AnswerRe: How do I execute a class from a class? Pin
Charlie Williams31-Jan-05 7:17
Charlie Williams31-Jan-05 7:17 
GeneralRe: How do I execute a class from a class? Pin
DSLR31-Jan-05 7:58
DSLR31-Jan-05 7:58 
GeneralRe: How do I execute a class from a class? Pin
Charlie Williams31-Jan-05 8:36
Charlie Williams31-Jan-05 8:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.