run fortran code with vb.net gui

GeorgeBenson

Member
Joined
Jan 19, 2007
Messages
9
Programming Experience
1-3
hello.
I want to run my own fortran codes with a vb.net gui. if i run really simple codes with no input, no output files and no subroutines, it works. i use visual basic, and it is really simple to create a gui that can handle simple programs. i also can start programs like word, excel, ... with the files i want to open.

but i cannot run my own codes :eek:
if my fortran code requires input / output files it won´t work. also i cannot run codes with subroutines. my big code has several subroutines in different .f files. how can i get this thing to work? i have no idea what i am doing wrong.
if i click on the .exe files of my fortran code, everything works just fine. i thought maybe it is because of a wrong directory somewhere in the .exe file. but it does not depend on the directory.

there is no help on the net. i feel like the only person in this world, who wants to create a gui for a little bit more sophisticated programs than "hello world" ;)

i really appreciate your help on this. i cannot solve my problems by myselve.

thanks a lot.

greetings to all you experts out there.
 
Look at the top of this thread, it says name of forum post is in. Look further up this page where you can read the full navigation path of forum section and subforum you are currently viewing (in the main menu navigation panel). Notifications from your subscribed threads (that you have posted to or subscribed to) also link directly back to the correct thread.
 
If you have an executable you can use the System.Diagnostics.Process class to execute it even with parameters; the language in which it was programmed is irrelevant.
i feel like the only person in this world, who wants to create a gui for a little bit more sophisticated programs than "hello world"
I assure you that there are many application created with .NET that are far more sophisticated than "hello world", and there is an abundance of information on the internet regarding .NET application development, this forum is one such example.
 
Last edited:
thanks for your help. but does not work :)

Hi ! I appreciate your help. But in my case it won´t work. I need to somehow declare input and output files for my .exe-file i am running with the vb.net gui.
Do you know how to do this?

Thanks a lot for your help.
 
Look up the Process class, there are examples everywhere on how to do that. There's even a link in my previous post to examples on MSDN. :confused:

To get better help it would behoove you to say why something didn't work instead of "it won't work". Give error messages if applicable, tell what it did or didn't do. I can usually read minds but for some reason it's not working today.
 
Do you mean supplying command parameters to the exe? which does: process.start("exe","params")
 
thanks a lot for your fast response !
I want to run a fairly complicated code. it is a .exe that needs a couple of input files (.dat or something) and will create a couple of output files (.dat or something). If i click on the .exe with the mouse it will work. But I am somehow not able to do this with a vb.net gui !!! :confused:

I can run easier codes that would not require input / output and i think the easy codes have no subroutines which should not matter since i run .exe files.

thanks again for your help !!!
 
sorry ... did not see the first reply. wow ! two replies within hours ! :) ! thanks

there are no error messages. the code starts running and my "message box" will pop up telling that the program has ended. but it did not start running. i cannot see the output window from my program, since it stops instantly. i think i can not find the input files. how would i do this !

thanks again. this starts to keep me from sleeping ... i just cannot figure it out.

i have to admid that i have never used any vb or vb.net before. i just do it by trail and error with visual studio.net which works quiet well for simple problems.
 
Just a guess: If there are spaces in the file paths (the parameters) you will need to enclose the file path in quotes just as you would if running from the command prompt.
If not show us the code used.
 
VB.NET:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles Button2.Click
Dim marker As Integer
marker = 0
If File.Exists("d:\Beobachter.plt") Then
marker = marker + 1
Else
MsgBox("Datei 'Beobachter.plt' ist nicht vorhanden.")
End If
If File.Exists("d:\input.pth") Then
marker = marker + 1
Else
MsgBox("Datei 'input.pth' ist nicht vorhanden.")
End If
If File.Exists("d:\variablen.cmn") Then
marker = marker + 1
Else
MsgBox("Header-Datei 'variablen.cmn' ist nicht vorhanden.")
End If
If marker = 3 Then
Dim Main As New System.Diagnostics.Process
Main.StartInfo.FileName = "d:\main.exe"
Main.Start()
Main.WaitForExit()
If Main.WaitForExit(600000) = True Then
MessageBox.Show("Die gestartete Anwendung " & _
Main.StartInfo.FileName & _
" wurde beendet.")
Else
MessageBox.Show("Die gestartete Anwendung " & _
Main.StartInfo.FileName & _
" ist auch nach 10 Min noch aktiv." & _
"Anwendung wird beendet.")
End If
Else
MsgBox("Programm kann nicht gestartet werden.")
End If
End Sub



So the paths work just fine. I am just not able to run my .exe ! The executable requires the 3 mentioned inputfiles. If I start the exe manually, it works just fine.

I really appreciate your help !!! :)
 
Last edited by a moderator:
but you didn't set any arguments?? Main.StartInfo.Arguments ="argument1 argument2 argument3"
If you start your app from command-line with "app.exe argument1 argument2 argument3", and programmatically with only "app.exe", would you expect the app to invent the arguments itself?
 
Back
Top