I have a simple form containing just 1 textbox and calling a separate class. I am having some difficulty getting the class to be able to access the form's controls. I can get 'step 1' to work but not 'step 2'.
Any ideas?
- ASPninja
VB.NET:
Public Class Form1
Public watchfolder As System.IO.FileSystemWatcher
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
watchfolder = New System.IO.FileSystemWatcher()
watchfolder.Path = "C:\Upload"
watchfolder.NotifyFilter = watchfolder.NotifyFilter Or IO.NotifyFilters.FileName
AddHandler watchfolder.Created, AddressOf logchange
watchfolder.EnableRaisingEvents = True
TextBox1.Text &= "Waiting for upload..." & vbCrLf
End Sub
Private Sub logchange(ByVal source As Object, ByVal e As System.IO.FileSystemEventArgs)
If e.ChangeType = IO.WatcherChangeTypes.Created Then
TextBox1.Text &= "File " & e.FullPath & " has been created" & vbCrLf
DoSomeStuff()
Dim c1 As New Class1
c1.DoSomeMoreStuff()
c1 = Nothing
End If
End Sub
Private Sub DoSomeStuff()
' ### Step 1 ###
TextBox1.Text &= "Step 1 is done." & vbCrLf
End Sub
End Class
Public Class Class1
Public Sub DoSomeMoreStuff()
' ### Step 2 ###
Form1.TextBox1.Text &= "Step 2 is done." & vbCrLf
End Sub
End Class
Any ideas?
- ASPninja