Click here to Skip to main content
15,891,375 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi

I wrote a Sub And put it in the module.and the Sub is here:

VB
Public Sub nnh()
    Me.Text = "%%%%"
End Sub


And at the click of a button event, I wrote this code will not run!

VB
CheckForIllegalCrossThreadCalls = False
t1 = New System.Threading.Thread(AddressOf nnh)
t1.Start()


Where is the problem?



Thank you.
Posted
Comments
LaxmikantYadav 15-Dec-11 7:45am    
Are both code samples under same namespace ?
sara.solati68 15-Dec-11 8:29am    
yes
Sergey Alexandrovich Kryukov 15-Dec-11 8:37am    
What's the declaring type of nnh? And, generally, can you make a complete code sample so you could compile. What exactly is "not working"?
--SA
sara.solati68 15-Dec-11 9:02am    
well it,s:this code not run!!!
Me.Text = "%%%%"

First, remove the "CheckForIllegalCrossThreadCalls" line. Setting that to False is NEVER a good idea.

You cannot modify controls from anything other than the thread that create it, namely the startup, or UI, thread.

Read this[^] to learn how to do it correctly.
 
Share this answer
 
Comments
sara.solati68 15-Dec-11 13:31pm    
I need more Help.
Dave Kreskowiak 15-Dec-11 14:42pm    
Boy, there's specific. Help with what? No, I'm not explaining to you how to redesign your entire applciation.
F1 F1 F1 F1 F1 F1 F1 F1 F1 F1 F1
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900