Click here to Skip to main content
15,905,683 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Object reference not set to an instance of an object Pin
Dave Kreskowiak1-Apr-05 13:42
mveDave Kreskowiak1-Apr-05 13:42 
GeneralRe: Object reference not set to an instance of an object Pin
VB .NET Newbie1-Apr-05 15:26
sussVB .NET Newbie1-Apr-05 15:26 
GeneralCapslock status Pin
Mr Dabbah1-Apr-05 9:12
Mr Dabbah1-Apr-05 9:12 
GeneralRe: Capslock status Pin
Anonymous1-Apr-05 18:41
Anonymous1-Apr-05 18:41 
QuestionDrive mount/dismount notification ? Pin
MrBean1-Apr-05 5:03
MrBean1-Apr-05 5:03 
AnswerRe: Drive mount/dismount notification ? Pin
Anonymous3-Apr-05 9:34
Anonymous3-Apr-05 9:34 
AnswerRe: Drive mount/dismount notification ? Pin
Anonymous3-Apr-05 9:59
Anonymous3-Apr-05 9:59 
GeneralAccessor Properties in Forms Pin
maxmanzero1-Apr-05 4:58
maxmanzero1-Apr-05 4:58 
Greetings All,

I am having trouble with a concept in VB.NET. I am trying to write and accessor property in a form so that I can change the text of a textbox from a subroutine in a class that I have written. However I cannot seem to get to the accessor property for the form within the class. Is this not possible? Here is the code for the property and the class. The class is instantiated in the form.

Form Code

Imports System.Threading

Public Class Form1
Inherits System.Windows.Forms.Form

Dim i As Integer
Dim clock As New Ticker
Dim cb As New TimerCallback(AddressOf clock.Tik)
Dim timer As Timer

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'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

'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.
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend Shared WithEvents txt1 As System.Windows.Forms.TextBox
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
<system.diagnostics.debuggerstepthrough()> Private Sub InitializeComponent()
Me.Button1 = New System.Windows.Forms.Button
Me.Button2 = New System.Windows.Forms.Button
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.SuspendLayout()
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(8, 4)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(106, 44)
Me.Button1.TabIndex = 1
Me.Button1.Text = "Start Timer"
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(120, 4)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(106, 44)
Me.Button2.TabIndex = 2
Me.Button2.Text = "Stop Timer"
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(14, 56)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(208, 20)
Me.TextBox1.TabIndex = 3
Me.TextBox1.Text = ""
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(242, 87)
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Button1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)

End Sub

#End Region

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
timer = New Timer(cb, Nothing, 0, 1000)
End Sub

Public Property setText() As String
Set(ByVal Value As String)
TextBox1.Text = Value
End Set
Get
Return TextBox1.Text
End Get
End Property

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
timer.Dispose()
txt1.Text = "Timer Disposed"
End Sub
End Class


Class Code

Imports HWINTERFACELib

Public Class Ticker

Dim i As Integer

'Dim hw As New HwinterfaceClass

Public Sub Tik(ByVal obj As Object)
i += 1
'hw.OutPort(&H400, 62)
Form1.setText = i.ToString ' <--- doesn't work?
End Sub


End Class


Thanks in advance
GeneralRe: Accessor Properties in Forms Pin
carlos_rocha3-Apr-05 23:08
carlos_rocha3-Apr-05 23:08 
GeneralIMAP Client Pin
M4nj_j1-Apr-05 4:37
M4nj_j1-Apr-05 4:37 
Questionplaying mpeg files How? Pin
stevekhan1-Apr-05 4:23
stevekhan1-Apr-05 4:23 
GeneralHelp file not getting focus on Dialog Form Pin
Rizwan Bashir1-Apr-05 1:38
Rizwan Bashir1-Apr-05 1:38 
GeneralRe: Help file not getting focus on Dialog Form Pin
Dave Kreskowiak1-Apr-05 2:23
mveDave Kreskowiak1-Apr-05 2:23 
GeneralRe: Help file not getting focus on Dialog Form Pin
Rizwan Bashir1-Apr-05 20:15
Rizwan Bashir1-Apr-05 20:15 
GeneralSave Pictures Pin
RajithCAlwis1-Apr-05 1:36
RajithCAlwis1-Apr-05 1:36 
GeneralRe: Save Pictures Pin
bodespace1-Apr-05 1:51
bodespace1-Apr-05 1:51 
Generallook for dominant color in bitmap Pin
bodespace1-Apr-05 0:59
bodespace1-Apr-05 0:59 
GeneralRe: look for dominant color in bitmap Pin
Dave Kreskowiak1-Apr-05 2:20
mveDave Kreskowiak1-Apr-05 2:20 
GeneralRe: look for dominant color in bitmap Pin
bodespace1-Apr-05 2:39
bodespace1-Apr-05 2:39 
GeneralDynamic Controls Pin
Sumit Domyan1-Apr-05 0:54
Sumit Domyan1-Apr-05 0:54 
GeneralRe: Dynamic Controls Pin
Dave Kreskowiak1-Apr-05 2:19
mveDave Kreskowiak1-Apr-05 2:19 
Generalbug(or my problem) in File.Open using FileShare.Write Pin
carlos_rocha1-Apr-05 0:41
carlos_rocha1-Apr-05 0:41 
GeneralRe: bug(or my problem) in File.Open using FileShare.Write Pin
Dave Kreskowiak1-Apr-05 2:17
mveDave Kreskowiak1-Apr-05 2:17 
GeneralRe: bug(or my problem) in File.Open using FileShare.Write Pin
carlos_rocha1-Apr-05 2:20
carlos_rocha1-Apr-05 2:20 
GeneralXML Transform Pin
nitin_ion31-Mar-05 23:12
nitin_ion31-Mar-05 23:12 

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.