Click here to Skip to main content
15,902,032 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
VB
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If File.Exists("c:\hi.txt") Then
            Me.Hide()
            successform.Show()
        Else
            Me.Show()
        End If
    End Sub

when hi.txt file exits successform.show() only should visible then self form should close. but i am getting both form even though hi.txt exists
Posted
Updated 31-Aug-12 21:17pm
v2

1 solution

Umapathi K asked:
self form should close
This could not be if done if processes are not interrelated to the program.
Try this:
VB
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If File.Exists("c:\hi.txt") Then
            Me.Hide()
            successform.Show()
        Else
            Me.Show()
            successform.Hide()'You missed this.
        End If
    End Sub


You missed to hide the successform.

--Amit
 
Share this answer
 
v2
Comments
Umapathi K 1-Sep-12 3:36am    
when hi.txt file exits successform.show() only should visible then self form should close. but i am getting both form, even though hi.txt exists . i.e consider if condition
_Amy 1-Sep-12 3:40am    
You are checking File.Exists("c:\hi.txt"). Is checking whether the file is there in your c drive or not. Use System.Diagnostics.Process to check the process. Then check your file whether it is opened in the current process or not. :)
Umapathi K 1-Sep-12 3:41am    
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If File.Exists("C:\WINDOWS\tscc.txt") Then
Me.Hide() 'it should get hide
successform.Show()
Else
Me.Show()
successform.Hide()
End If
End Sub
Umapathi K 1-Sep-12 3:45am    
yes its checking

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900