|
-
Apr 14th, 2007, 05:41 AM
#1
Thread Starter
Member
shell and datagrid problems (newbie needs help)
I have been given the dubious task of writing a front end to a data processing tool, basicly the front end needs to write a text file, it should then call the data processor(dos based fortran) the data processor then produces two output files.
I have used shell ("d:\matt\matt.exe", appwinstyle.maximisedfocus) this appears to call the dos based processor but it then closes down straight away without processing the file. If I double click the data processor, through windows explorer, it processes the file correctly.
Couple of questions:
What am I doing wrong - why does the dos file processor see the text file when manually started but not when started via VB?
What is the correct way of starting the dos file and then when the dos program returns control to the calling program, it continuing on it's merry way?
datagrids:
I am having a total brain fart with this...
I have a form with 22 datagrid controls on it, they are populated from an Access database. I am wanting to read the data from the datagrid controls, the access data provides base data that the user may want to modify, but I can't for the life of me think how to do it. I know in VB6B you could set up a control array, but can this be done in .net 2003?
regards,
Matt
-
Apr 14th, 2007, 06:31 AM
#2
Re: shell and datagrid problems (newbie needs help)
1. Don't use Shell() in .NET apps. Use Process.Start().
2. Where is this input data file located and how does the data processor know how to find it if you aren't specifying its path in the commandline? Is it because it is located in the same folder as the EXE? In that case it's probably using the current directory. If you run the EXE from Windows Explorer then the current directory will be the folder containing that executable. If you run the EXE by calling Shell() the current directory will be the folder containing YOUR executable. If you want the process you start to use a specific working directory then you have to set it, e.g.
vb Code:
Dim exePath As String = "D:\Matt\Matt.exe"
Dim psi As New ProcessStartInfo(exePath)
psi.WindowStyle = ProcessWindowStyle.Maximized
psi.WorkingDirectory = IO.Path.GetDirectoryName(exePath)
Process.Start(psi)
As for your DataGrid question, can you please ask unrelated questions in separate threads?
-
Apr 14th, 2007, 06:38 AM
#3
Thread Starter
Member
Re: shell and datagrid problems (newbie needs help)
Thanks for the reply, will try that later.
Sorry about dual question single posting will start a new post, reason for doing it was the two questions are for the same project.
regards,
Matt
-
Apr 17th, 2007, 02:13 PM
#4
Thread Starter
Member
Re: shell and datagrid problems (newbie needs help)
I have tried what was suggested above but all it does is open a dos box which then closes down - same as shell("d:\matt\matt.exe"), appwinstyle.maximisedfocus)
It doesn't appear to be running the dos app as nothing appears in the dos box, however, when using the same code but deliberately pointing it to an incorect file or location the program throws an exception. Also if I point the code to cmd.exe or notepad.exe it opens up the command prompt and notepad perfectly.
Any help would be appreciated.
regards,
Matt
-
Apr 17th, 2007, 02:38 PM
#5
Re: shell and datagrid problems (newbie needs help)
If there is an error with the Matt.exe file then it will close right away. Does it need a certain working directory or passed in arguments?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Apr 17th, 2007, 02:43 PM
#6
Thread Starter
Member
Re: shell and datagrid problems (newbie needs help)
The program is a compiled fortran application, you run it and it prompts for a filename to process after receiving the filename it goes and produces a couple of results files.
If I double click the exe file in explorer it opens up and runs fine.
If I call it using the shell command of VB6 it works fine - well it opens up it just won't accept the input file.
It just seems that VB.NET is doing something differnt and I aint got a clue as to what?
regards,
Matt
-
Apr 17th, 2007, 02:48 PM
#7
Re: shell and datagrid problems (newbie needs help)
Isnt it expecting a file as an argument then? Are you setting the working directory as shown?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Apr 17th, 2007, 02:53 PM
#8
Thread Starter
Member
Re: shell and datagrid problems (newbie needs help)
I have set the working directory as shown above, also tried it in a test directory, on the c drive, on the d drive, etc, etc and it still just brings up a black screen which opens then closes immediately.
My first instinct is that for some reason it isn't being allowed to open the fortran exe file, because if I point the exe to one that doesn't exist it throws up an error - therefore it must see a file as such but just can't open it.
As I said I am novice to this so...
regards,
Matt
-
Apr 17th, 2007, 02:57 PM
#9
Re: shell and datagrid problems (newbie needs help)
The code seems fine but perhaps try adding ...
psi.UseShellExecute = True
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Apr 17th, 2007, 02:59 PM
#10
Thread Starter
Member
Re: shell and datagrid problems (newbie needs help)
Will give it a go tommorow - I don't have the source code at home..
regards,
Matt
-
Apr 18th, 2007, 02:28 PM
#11
Thread Starter
Member
Re: shell and datagrid problems (newbie needs help)
I have managed to do a work around with this by writing a one line batch file that calls the exe. I then get vb.net to run the batch file and it works - don't know why but....
regards,
Matt
-
Apr 26th, 2007, 05:49 PM
#12
Re: shell and datagrid problems (newbie needs help)
I guess as long as it works 
Ps, dont forget to Resove your thread from the Thread Tools menu so other members will know its been solved.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Apr 27th, 2007, 03:38 AM
#13
Thread Starter
Member
Re: shell and datagrid problems (newbie needs help)
I have just found one other thing...
when the dos program is run it wants the user to input the name of the file and press enter for it then to be processed - can this be done? If so how.
I have tried alterring the batch file to see if it'll accept command line arguments but it doesn't seem to, so any ideas?
Bat file example:
matt.exe matt.txt
This doesn't work, it only runs the program and it then waits for the user to enter the filename.
regards,
Matt
-
Apr 27th, 2007, 04:40 AM
#14
Re: shell and datagrid problems (newbie needs help)
Can you post the batch file text?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Apr 29th, 2007, 05:28 AM
#15
Thread Starter
Member
Re: shell and datagrid problems (newbie needs help)
The batch file is just one line as shown in the example.
Matt.exe
I have tried
Matt.exe matt.txt
but the program, matt.exe, just loads and asks for the name of the txt file to be processed.
regards,
Matt
-
Apr 29th, 2007, 04:14 PM
#16
Re: shell and datagrid problems (newbie needs help)
It may be needing you to pass the path too? How are you parsing or expecting to receive the file in your matt.exe program?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Apr 30th, 2007, 12:06 PM
#17
Thread Starter
Member
Re: shell and datagrid problems (newbie needs help)
Rob,
When the exe file runs using the following bat file at the top of the screen it shows matt.exe matt.txt and the program matt.exe runs and asks for a file name to process.
bat file
matt.exe matt.txt
Is it possible to pass a command to the started process???
regards,
Matt
-
May 7th, 2007, 08:27 AM
#18
Thread Starter
Member
Re: shell and datagrid problems (newbie needs help)
Anyone have any ideas???
regards,
Matt
-
May 12th, 2007, 04:27 PM
#19
Re: shell and datagrid problems (newbie needs help)
Yes, you can passit it the .Arguments parameter of either the Process or the ProcessStartInfo class
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
May 17th, 2007, 01:05 PM
#20
Thread Starter
Member
Re: shell and datagrid problems (newbie needs help)
Rob,
This will only work if the program accepts command line arguments, which mine doesn't.
Had a brief conversation with a VB6 programmer and he said to do it via API calls - Would this be possible?
regards,
Matt
-
Jan 28th, 2008, 01:23 PM
#21
Thread Starter
Member
Re: shell and datagrid problems (newbie needs help)
Sorry for resurrecting this, but have found a problem when running the program via it's exe as opposed to running it through Visual Studio
dim opsi as new processStartInfo(exepath)
dim oprocess as New Process
opsi.useshellexecute = false
opsi.redirectstandardinput = true
opsi.workingdirectory = IO.Path.GetdirectoryName(exepath)
oprocess = process.start(opsi)
oprocess.standardinput.writeline(inpfile)
oprocess.waitforexit()
Now when I run this in Visual Studio, all is well and the file gets processed, however, now I have come to distribute the app I run into the following problems:
* When using any of the .exe files created in the bin directory it appears that the Dos program either isn't called ( a dos box appears briefly then shuts down) or the dos box doesn't receive the file name I am sending. This happens if I also run my programs exe from obj/debug and obj/release directories.
* If I change the redirectstandardinput to use shellexecute then the dos program is called and appears on screen waiting for the name of the file to be processed, but I can't seem to work out how to send the filename this way as the dos program doesn't accept arguments.
Initially I thought it was a problem with the machine I am passing the executable to but it also does the same on my development machine. What am I doing wrong?
regards,
Matt
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|