Hi,
I have a main form which creates a thread. I want to make this child thread open a OpenFileDialog, but whenever I try to do this I get:
ThreadStateExce ption.
Current thread must be set to single thread apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttrib ute marked on it. This exception is only raised if a debugger is attached to the process.
...
User Profile
Collapse
-
VB.NET 08 OpenFileDialog in 2nd Thread throws ThreadStateException
-
You can use
Code:DataGridView1.Rows.Insert(index, paramArray)
Wagz -
I'd enter the dates as a Date type and simply subtract the two. This will give you the difference in days, hours, minutes, seconds, milliseconds. It doesn't however give you the difference in months. To do that I might do something like
date2.Year*12 + date2.Month - date1.Year*12 - date1.Month
Wagz...Leave a comment:
-
jjvainav, I couldn't get your method to work.
I raised the event in Class1 and handled it in Form1, but when I go to change the text in Form2 it creates a new instance of Form2.
Code:Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Form2.Show() Form2.BringToFront() signal = New Class1()
Leave a comment:
-
If I pass Form2 to Class1 when I create it and create a delegate to handle the changing the text then it works.
I passed it in to Class1 in the constructor, is there a better way to do this? In the future I'd like to be able to possibly add additional forms and therefore don't necessarily want to have to have to modify the class every time I create a new form.
Below is the code I used:
Code:Public Class
Leave a comment:
-
It appears that every time I'm in the created thread and call something from form2 that it creates a new instance of the form. How do I reference the form that form1 created from the created thread?Leave a comment:
-
Accessing a form from a thread running on a second form
Hi,
I have a main form which starts up a thread as well as a 2nd form.
How do I make it so that I can access things such as labels on the 2nd form from the thread that was started on form1?
I have some sample code below...
Code:Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Form2.Show()
-
Dim curSales(1 to 5) As currency creates an array with indexes 1 through 5 inclusive. Therefore the valid indexes are 1,2,3,4,5 and the 2nd if statement you wrote is the one you'd want to use to verify that intX is valid.
WagzLeave a comment:
-
You can use the Shell() function to run windows commands, so if you wanted to lock the computer you could try a command like
Code:Shell("rundll32.exe user32.dll, LockWorkStation")
Leave a comment:
-
If you want to use a macro to delete the zeros then you can use the following code
Code:For Each cell In Selection If cell = "0" Then cell.Delete End If Next
However you can also use search and replace edit option that you described, just make sure to check the "match entire...Leave a comment:
-
Serializing a Form
Hi,
I'm trying to save the state of a form in VB 2005 to a file so that the next time the program starts up the form will be reloaded to it's last state.
I did a bit of searching and it seemed to me that serialization is the way to accomplish this, but as far as I can tell you cannot serialize the entire form or just the controls on the form.
Therefore, I was hoping if someone could point me in the right...
No activity results to display
Show More
Leave a comment: