2 Replies - 3859 Views - Last Post: 07 October 2009 - 07:14 AM Rate Topic: -----

#1 gagan2004_2005  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 07-October 09

Splash Screen in VB.Net 2008

Posted 07 October 2009 - 06:35 AM

i have created a splash screen by removing form border and importing an image to the picture box. also i have set a timer for 7 sec after which the splash screen will close itself and will open the MDI form.
But after seven second altough the splash screen closes but it also closes the MDI form too. I am not able to figure out the problem.

Form1.vb
Public Class Form1

	Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

	End Sub

	Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
		Dim a As New MDIParent1()
		a.Show()
		Me.Close()
	End Sub

	Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
		Dim b As New MDIParent1()
		b.Show()
		Me.Close()
	End Sub
End Class



MDIParent1.vb
Imports System.Windows.Forms

Public Class MDIParent1

	Private Sub ShowNewForm(ByVal sender As Object, ByVal e As EventArgs) Handles NewToolStripMenuItem.Click, NewWindowToolStripMenuItem.Click
		' Create a new instance of the child form.
		Dim ChildForm As New System.Windows.Forms.Form
		' Make it a child of this MDI form before showing it.
		ChildForm.MdiParent = Me

		m_ChildFormNumber += 1
		ChildForm.Text = "Window " & m_ChildFormNumber

		ChildForm.Show()
	End Sub

	Private Sub OpenFile(ByVal sender As Object, ByVal e As EventArgs) Handles OpenToolStripMenuItem.Click
		Dim OpenFileDialog As New OpenFileDialog
		OpenFileDialog.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.MyDocuments
		OpenFileDialog.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*"
		If (OpenFileDialog.ShowDialog(Me) = System.Windows.Forms.DialogResult.OK) Then
			Dim FileName As String = OpenFileDialog.FileName
			' TODO: Add code here to open the file.
		End If
	End Sub

	Private Sub SaveAsToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles SaveAsToolStripMenuItem.Click
		Dim SaveFileDialog As New SaveFileDialog
		SaveFileDialog.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.MyDocuments
		SaveFileDialog.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*" 

		If (SaveFileDialog.ShowDialog(Me) = System.Windows.Forms.DialogResult.OK) Then
			Dim FileName As String = SaveFileDialog.FileName
			' TODO: Add code here to save the current contents of the form to a file.
		End If
	End Sub


	Private Sub ExitToolsStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ExitToolStripMenuItem.Click
		Me.Close()
	End Sub

	Private Sub CutToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles CutToolStripMenuItem.Click
		' Use My.Computer.Clipboard to insert the selected text or images into the clipboard
	End Sub

	Private Sub CopyToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles CopyToolStripMenuItem.Click
		' Use My.Computer.Clipboard to insert the selected text or images into the clipboard
	End Sub

	Private Sub PasteToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles PasteToolStripMenuItem.Click
		'Use My.Computer.Clipboard.GetText() or My.Computer.Clipboard.GetData to retrieve information from the clipboard.
	End Sub

	Private Sub CascadeToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles CascadeToolStripMenuItem.Click
		Me.LayoutMdi(MdiLayout.Cascade)
	End Sub

	Private Sub TileVerticalToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles TileVerticalToolStripMenuItem.Click
		Me.LayoutMdi(MdiLayout.TileVertical)
	End Sub

	Private Sub TileHorizontalToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles TileHorizontalToolStripMenuItem.Click
		Me.LayoutMdi(MdiLayout.TileHorizontal)
	End Sub

	Private Sub ArrangeIconsToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ArrangeIconsToolStripMenuItem.Click
		Me.LayoutMdi(MdiLayout.ArrangeIcons)
	End Sub

	Private Sub CloseAllToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles CloseAllToolStripMenuItem.Click
		' Close all child forms of the parent.
		For Each ChildForm As Form In Me.MdiChildren
			ChildForm.Close()
		Next
	End Sub

	Private m_ChildFormNumber As Integer

	Private Sub MDIParent1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

	End Sub
End Class



Kindly reply asap
Thanking you
Gagandeep Singh

Is This A Good Question/Topic? 0
  • +

Replies To: Splash Screen in VB.Net 2008

#2 motcom  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 290
  • View blog
  • Posts: 1,371
  • Joined: 16-June 08

Re: Splash Screen in VB.Net 2008

Posted 07 October 2009 - 06:56 AM

Hi,

instead of this,

Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
		Dim a As New MDIParent1()
		a.Show()
		Me.Close()
	End Sub

	Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
		Dim b As New MDIParent1()
		b.Show()
		Me.Close()
	End Sub





try this

Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
		Timer1.Enabled = False
		Dim a As New MDIParent1()
		Me.Hide()
		a.ShowDialog() 
		Me.Close()
	End Sub

	Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
		Timer1.Enabled = false
		Dim b As New MDIParent1()
		Me.Hide()
		b.ShowDialog()
		Me.Close()
	End Sub



This post has been edited by motcom: 07 October 2009 - 06:56 AM

Was This Post Helpful? 0
  • +
  • -

#3 magius96  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 71
  • View blog
  • Posts: 774
  • Joined: 15-April 09

Re: Splash Screen in VB.Net 2008

Posted 07 October 2009 - 07:14 AM

Another method of controlling your splash screen is to let your main form control the splash screen.

When your main form loads, set it's visible property to false, then load the splash screen. Then, let your main form close the splash screen and set it's visible property back to true. By this method, there is no actual coding to be done in the splash screen, as everything is done by the main form.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1