Cor,
With option strict ON
the provided code would raise 2 errors
option strict requires all variabels to have an as clause
name Test is not declared ( as it is method scoped )
so it wouldn`t even compile
if run with option strict off it would also not compile because of some
coding errors
However this could run ( although not my prog style ) in this way
>>>This works
Imports System.Threading
Public Class Form1
Private test As New Class1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
test.a = 1
test.b = 2
test.c = 3
Dim t As Thread
t = New Thread(AddressOf Me.doit)
t.Start()
End Sub
Sub doit()
Dim a As Integer = test.a ' now you get 1 :-)
End Sub
End Class
Public Class Class1
Public a As Integer
Public b As Integer
Public c As Integer
End Class
"Cor Ligthert [MVP]" wrote:
Hi mr Arnold,
Can you tell us why option strict should be off. At least (I am sure of)
both Armin and I are very interested in that.
Cor
"Mr. Arnold" <MR. Ar****@Arnold.comschreef in bericht
news:uA**************@TK2MSFTNGP05.phx.gbl...
"nondos" <no****@nondos.orgwrote in message
news:GM******************************@giganews.com ...
Hello
I have a problem with thread i have a class defntion i've create but
every time i call it from thread it's null any idea why?
code:
dim test as class1
test.a=1
test.b=2
test.c =3
Dim t As Thread
t = New Thread(AddressOf Me.DoIt)
t.Start()
sub doit()
dim a = test.a ' i get null
end sub
Public Shared Class Class1
Public Shared a As Integer
Public Shared b As Integer
Public Shared c As Integer
End Class
Then you can use Class1.a = test.a
Use Goggle or go to the VS Help and look-up the *Shared* keyword and find
out what it does.
Either you have to instantiate class1 with Dim class1 = new class1 at some
point or you use the Shared keyword.
It should have not compiled or blew up IMHO. I don't know how you got away
with it. You must have Option Strict turned off for the project.