Answered on error goto?

Jyy

New member
Joined
Jul 17, 2008
Messages
3
Programming Experience
Beginner
hello, i don't really understand my mistake. i want to make an "Run" button on my project, this is my code for so far:
Code:
        Dim a
        a = InputBox("What do you want to run?", "Run...", "regedit")
        Shell(a, 1)
        On Error GoTo runerror
runerror:
        MsgBox("Error! File doesn't exist!", MsgBoxStyle.Exclamation + 0, "Error!")
now when he opens something that doesn't have to give an error, he gives the error i made with runerror. when he can't open it, he gives an error: "File not found."
then the whole program stops running...
can someone help me?
 
Last edited:

JuggaloBrotha

VB.NET Forum Moderator
Staff member
Joined
Jun 3, 2004
Messages
4,524
Location
Lansing, MI; USA
Programming Experience
10+
It looks like you're using vb6 code with windows script code.

Make a form that has a label, a textbox and a button. Give them names, the textbox is for the user to type in what they want to run and the button's for running their program.

In the button's click event put code similar to this:
Code:
  If System.IO.File.Exists(Textbox1.Text.Trim) Then System.Diagnostics.Process.Start(Textbox1.Text.Trim)
 

Jyy

New member
Joined
Jul 17, 2008
Messages
3
Programming Experience
Beginner
that's my problem. i'm using 2008 and this is compatible with 2008 for as far as i know. what's wrong with using your code: regedit doesn't exist for as far as i know as a map but you are able to run it instead. the same with %windir%, %temp%, cmd, etc.

edit: i've now got it right, i used try, catch ex as exception, end try. but still i can't make a browse.
 
Last edited:

Jyy

New member
Joined
Jul 17, 2008
Messages
3
Programming Experience
Beginner
i've tried to make a browse button in it, for now i'm so far:
Code:
        Dim browsedialog As New OpenFileDialog()
        browsedialog.CheckFileExists = True
        browsedialog.Title = "Browse"
        browsedialog.ShowDialog(Me)
how do i get the root + the file itself into run(textbox1.text)?
 

JuggaloBrotha

VB.NET Forum Moderator
Staff member
Joined
Jun 3, 2004
Messages
4,524
Location
Lansing, MI; USA
Programming Experience
10+
i've tried to make a browse button in it, for now i'm so far:
Code:
        Dim browsedialog As New OpenFileDialog()
        browsedialog.CheckFileExists = True
        browsedialog.Title = "Browse"
        browsedialog.ShowDialog(Me)
how do i get the root + the file itself into run(textbox1.text)?
browsedialog.FileName is the complete path + the filename of the selected file.
 
Top Bottom