Hi all,

I'm hoping someone can help me with this as I can't for the life of me figure it out.

I have a single form called 'FolderSelector' with a label, textbox and a button.

The problem I'm having is that everytime I run the application, the only thing that shows up is a blank form called 'Form1', the program runs everything it should do except to show the actual form which is really weird.

Here's the code in case there's something in there that's causing it that I haven't spotted.

Imports System.IO.Directory

Public Class FolderSelector

    Public Const SPI_SETDESKWALLPAPER As Integer = &H14
    Public Const SPIF_UPDATEINIFILE As Integer = &H1
    Public Const SPIF_SENDWININICHANGE As Integer = &H2

    Public Declare Auto Function SystemParametersInfo Lib "user32.dll" (ByVal uAction As Integer, ByVal uParam As Integer, ByVal lpvParam As String, ByVal fuWinIni As Integer) As Integer

    Private Sub FolderSelector_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        TaskTrayIcon.Visible = False

        Dim rightNow As DateTime = DateTime.Now
        Dim strCurrentDateTimeStringYear As String
        Dim strCurrentDateTimeStringMonth As String

        strCurrentDateTimeStringYear = rightNow.ToString("yyyy")
        strCurrentDateTimeStringMonth = rightNow.ToString("MMMM")

        Dim imageLocation As String

        imageLocation = "D:\Images\Calendar\" & strCurrentDateTimeStringYear & "\" & strCurrentDateTimeStringMonth & ".jpg"

        Try
            SystemParametersInfo(SPI_SETDESKWALLPAPER, 1, imageLocation, SPIF_UPDATEINIFILE Or SPIF_SENDWININICHANGE)

        Catch Ex As Exception
            MsgBox("There was an error setting the wallpaper: " & Ex.Message)
        End Try

    End Sub

    Private Sub NotifyIcon1_MouseDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TaskTrayIcon.MouseDoubleClick

        Try
            Me.Show()
            Me.WindowState = FormWindowState.Normal
            TaskTrayIcon.Visible = False

        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

    End Sub

    Private Sub FolderSelector_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize

        Try
            If Me.WindowState = FormWindowState.Minimized Then
                Me.WindowState = FormWindowState.Minimized
                TaskTrayIcon.Visible = True
                Me.Hide()
            End If

        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

    End Sub

    Private Sub DateCheck_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateCheck.Tick

        Dim rightNow As DateTime = DateTime.Now

        Dim strCurrentDateTimeStringYear As String
        Dim strCurrentDateTimeStringMonth As String

        strCurrentDateTimeStringYear = rightNow.ToString("yyyy")
        strCurrentDateTimeStringMonth = rightNow.ToString("MMMM")

        Dim imageLocation As String

        imageLocation = "D:\Images\Calendar\" & strCurrentDateTimeStringYear & "\" & strCurrentDateTimeStringMonth & ".jpg"

        Try
            SystemParametersInfo(SPI_SETDESKWALLPAPER, 1, imageLocation, SPIF_UPDATEINIFILE Or SPIF_SENDWININICHANGE)

        Catch Ex As Exception
            MsgBox("There was an error setting the wallpaper: " & Ex.Message)
        End Try

    End Sub

    Private Sub btnBrowse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBrowse.Click

        Dim MyFolderBrowser As New System.Windows.Forms.FolderBrowserDialog

        ' Descriptive text displayed above the tree view control in the dialog box
        MyFolderBrowser.Description = "Select the Folder"

        ' Do not show the button for new folder
        MyFolderBrowser.ShowNewFolderButton = False

        Dim dlgResult As DialogResult = MyFolderBrowser.ShowDialog()

        If dlgResult = Windows.Forms.DialogResult.OK Then
            txtFolder.Text = MyFolderBrowser.SelectedPath
        End If

    End Sub
End Class

Thanks
TheMightySpud

See if this helps.

File Menu/Project/"your app's name" Properties.../Application tab.
.Set "Startup form:" to your Form, not Form1.

Thanks for the reply,

Already checked that :-/

It's really weird as there isn't a 'Form1' in my project. :-/

LOL. The mysterious Form1. :D

Your project might have gotten bugged somehow since vb.net does tend to come up with a few bugs here and there.

Suggestion: Try to create a new project.

i think your InitializeComponent() method in designer is not being called correctly , that's why there is no controls in your form..

check the method.

try placing this code in your Form1:

Public Sub New()

        ' This call is required by the Windows Form Designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.

    End Sub

Hi all,

Thanks for the reply, I created a new project as was suggested and all is working as it should. :)

Thanks
TheMightySpud

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.