daveydave400 Posted September 26, 2005 Posted September 26, 2005 Alright I want to make a simple start up program where I have a list of Names of Programs with check boxes next to them. I have it so if you click on the Yes button it uses if commands to open what ever program(s) were checked. The First Part - I want to add a button for OpenFileDialog so if a program is not listed, then a user can select the .exe file they want to run or a .doc file instead of just word, but I have it all worked out except for I can't open the file would anyone please tell me the code to open a file from an openfiledialog box, I know its simple but for some reason I am just missing something (It is more for other programs because otherwise I can just use "The Second Part"). The Second Part - For the Yes button I want to have it so if openfiledialog1.filename = anything with a filename(or later a filtered extension) then open that filename but I cant get it to let me put *.* or *.doc. So my question is what do I put If OpenFileDialog1.FileName = (*.*) Then System.Diagnostics.Process.Start(OpenFileDialog1.FileName) How do I go about this? If anyone has any clue on how to fix my problem please help, much appreciated. Thanks P.S. If anyone knows any websites that are similar to ebypass.org for getting past school district filters on websites please list some, I think my school is filtering ebypass.org now or something cuz it doesnt work there but it does at home. Quote
Leaders dynamic_sysop Posted September 26, 2005 Leaders Posted September 26, 2005 (edited) you need to specify *.* as the Filter property, then check the DialogResult on ShowDialog eg: [size=2][color=#0000ff]Dim[/color][/size][size=2] OpenFileDialog1 [/size][size=2][color=#0000ff]As [/color][/size][size=2][color=#0000ff]New[/color][/size][size=2] OpenFileDialog[/size] [size=2] OpenFileDialog1.Filter = "All Files|*.*" [/size][size=2][color=#0000ff]If[/color][/size][size=2] OpenFileDialog1.ShowDialog = DialogResult.OK [/size][size=2][color=#0000ff]Then[/color][/size] [size=2][color=#0000ff] [/color][/size][size=2] Process.Start(OpenFileDialog1.FileName) [/size][size=2][color=#0000ff]End [/color][/size][size=2][color=#0000ff]If[/color][/size] Edited September 26, 2005 by dynamic_sysop Quote
daveydave400 Posted September 27, 2005 Author Posted September 27, 2005 Not totally understood Alright but you didnt totally understand what I said: http://members.fortunecity.com/daveydave400/Assets/programimage.jpg I want a user to be able to click on the "Run Other" button and a openfiledialog box opens they select anyfile and then after the click ok or open or w/e then they have to click the "Yes" button and it will open all checked programs and also the file that the user specified. So it might say something like: Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim OpenFileDailog1 As New OpenFileDialog End Sub Private Sub runother_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles runother.Click OpenFileDialog1.Filter = "Executable Files (*.exe) | *.exe | Word Documents (*.doc) | *.doc| All Files (*.*)| *.*" OpenFileDialog1.InitialDirectory = "C:\" OpenFileDialog1.ShowDialog() MsgBox(OpenFileDialog1.FileName) End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click If Yes1.Checked = True Then System.Diagnostics.Process.Start("C:\Program Files\LimeWire\Limewire.exe") If Yes2.Checked = True Then System.Diagnostics.Process.Start("C:\Program Files\MSN Messenger\msnmsgr.exe") If Yes3.Checked = True Then System.Diagnostics.Process.Start("C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE\devenv.exe") If OpenFileDialog1.ShowDialog = DialogResult.OK Then System.Diagnostics.Process.Start(OpenFileDialog1.FileName) If Yes4.Checked = True Then System.Diagnostics.Process.Start("C:\Program Files\Microsoft Office\Office10\WINWORD.exe") If Yes5.Checked = True Then System.Diagnostics.Process.Start("C:\Program Files\Internet Explorer\IEXPLORE.EXE") If Yes6.Checked = True Then System.Diagnostics.Process.Start("C:\Program Files\Windows Media Player\wmplayer.exe") End End Sub What you told me opens an openfiledialog box when i click "yes" as well as "Run other". Maybe now you can help me more directly. Thanks Anyway. Quote
Administrators PlausiblyDamp Posted September 28, 2005 Administrators Posted September 28, 2005 In the button2 click event you do not need to call ShowDialog again, try something like Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click If Yes1.Checked = True Then System.Diagnostics.Process.Start("C:\Program Files\LimeWire\Limewire.exe") If Yes2.Checked = True Then System.Diagnostics.Process.Start("C:\Program Files\MSN Messenger\msnmsgr.exe") If Yes3.Checked = True Then System.Diagnostics.Process.Start("C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE\devenv.exe") if OpenFileDialog1.FileName <> String.empty then System.Diagnostics.Process.Start(OpenFileDialog1.FileName) If Yes4.Checked = True Then System.Diagnostics.Process.Start("C:\Program Files\Microsoft Office\Office10\WINWORD.exe") If Yes5.Checked = True Then System.Diagnostics.Process.Start("C:\Program Files\Internet Explorer\IEXPLORE.EXE") If Yes6.Checked = True Then System.Diagnostics.Process.Start("C:\Program Files\Windows Media Player\wmplayer.exe") End Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
daveydave400 Posted September 30, 2005 Author Posted September 30, 2005 Thanks that works, I also found out that if you put DialogResult.Ok = 1 works but your way is better, more specific. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.