P
Paul
Is there any way of making the following code into a function so that I
don't have to re-use the same code for all my buttons? I've tried to do this
with the code at the bottom of my post but I get a build error saying 'Type
FormToShow is not defined'.
Cheers,
Paul
Private WithEvents Example1Form As frmDragDropFromExplorer
Private WithEvents Example2Form As frmDragDrop
Public Shared Sub Main()
Application.EnableVisualStyles()
Application.DoEvents()
Application.Run(New frmMain)
End Sub
Private Sub btnExample1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnExample1.Click
Try
Example1Form.Show()
Catch
Example1Form = New frmDragDropFromExplorer
Example1Form.Show()
Finally
Example1Form.Focus()
End Try
End Sub
---- Tried this but got the error 'FormToShow is not defined' ---
Private Sub btnExample1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnExample1.Click
ShowForm(Example1Form)
End Sub
Private Function ShowForm(ByVal FormToShow As Form)
Try
FormToShow.Show()
Catch
FormToShow = New FormToShow
FormToShow.Show()
Finally
FormToShow.Focus()
End Try
End Function
don't have to re-use the same code for all my buttons? I've tried to do this
with the code at the bottom of my post but I get a build error saying 'Type
FormToShow is not defined'.
Cheers,
Paul
Private WithEvents Example1Form As frmDragDropFromExplorer
Private WithEvents Example2Form As frmDragDrop
Public Shared Sub Main()
Application.EnableVisualStyles()
Application.DoEvents()
Application.Run(New frmMain)
End Sub
Private Sub btnExample1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnExample1.Click
Try
Example1Form.Show()
Catch
Example1Form = New frmDragDropFromExplorer
Example1Form.Show()
Finally
Example1Form.Focus()
End Try
End Sub
---- Tried this but got the error 'FormToShow is not defined' ---
Private Sub btnExample1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnExample1.Click
ShowForm(Example1Form)
End Sub
Private Function ShowForm(ByVal FormToShow As Form)
Try
FormToShow.Show()
Catch
FormToShow = New FormToShow
FormToShow.Show()
Finally
FormToShow.Focus()
End Try
End Function