Help creating command based application
I am just getting started with VB code, so bear with me...
I have 4 radio buttons that depending on which one is clicked it will go to a line in the command code (using the GOTO command).
So the question is - how do I get my batch scripts to work in an application window?
I am familiar with batch commands and executing batch files, so if there is a way for me to use batch commands within this but still get the application look; that would be great. I have it layed out, but have 28 erros in my code. Mostly "Declaration Expected" errors. I am using Visual Studio 2005. Any help would be greatly appreciated.
[646 byte] By [
bmccubbin] at [2007-11-11 11:57:14]

# 1 Re: Help creating command based application
Welcome to dev-archive :WAVE:
Post the code that you have.
Hack at 2007-11-11 20:42:41 >

# 2 Re: Help creating command based application
bmccubbin,
I didn't know that VB 2005 still had a GOTO command! At any rate, you should almost always avoid using GOTO.
You didn't mention your programming background, but I wonder if taking some courses at your local community or 4-year college might not be useful.
Kerry Moorman
# 3 Re: Help creating command based application
Thank you for the reply. I am just now trying to learn it so I don't have any background. At this time I am trying to simply copy different directories based on which radio button is selected. I am sure this is all butchered up, so any guidance would be great. Thanks.
Public Class Form1
If RadioButton1.Checked = True Then
Shell("cmd /c xcopy /E /Y /Q /C .\DM\desktop\* C:\documents and settings\mobile\desktop",vbHide)
Elseif RadioButton2.Checked = True Then
Shell("cmd /c xcopy /E /Y /Q /C .\Auditor\desktop\* C:\documents and settings\mobile\desktop",vbhide)
Shell("cmd /c xcopy /E /Y /Q /C .\Auditor\programs\* C:\",vbHide)
ElseIf RadioButton3.Checked = True Then
Shell("cmd /c xcopy /E /Y /Q /C .\realestate\desktop\* C:\documents and settings\mobile\desktop",vbHide)
ElseIf RadioButton4.Checked = True Then
Shell("cmd /c xcopy /E /Y /Q /C .\costrecovery\desktop\* C:\documents and settings\mobile\desktop",vbHide)
End If
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
# 4 Re: Help creating command based application
Ok, first off, if you are going to code in .NET, then code in .NET - not VB6, not DOS
To copy a folder using VB.NET doMy.Computer.FileSystem.CopyDirectory("c:\hack\", "d:\hack\")
Hack at 2007-11-11 20:45:37 >

# 5 Re: Help creating command based application
You probably want to perform the copy in response to some user action, like clicking a button. So you would put your code in a Button_Click event handler; to easily create one, double-click on the button on your form in Visual Studio's form designer. You'll get something like this:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
End Sub
End Class
Now you can put your code inside the Button1_Click procedure. The code you posted should work, or you can clean it up as Hack suggested:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim SourceDirectory As String
Dim DestinationDirectory As String = "C:\Documents and Settings\Mobile\Desktop"
If RadioButton1.Checked = True Then
SourceDirectory = ".\DM\desktop\*"
ElseIf RadioButton2.Checked = True Then
SourceDirectory = ".\Auditor\desktop\*"
My.Computer.FileSystem.CopyDirectory(".\Auditor\programs\*", "C:\")
ElseIf RadioButton3.Checked = True Then
SourceDirectory = ".\RealEstate\desktop\*"
ElseIf RadioButton4.Checked = True Then
SourceDirectory = ".\CostRecovery\desktop\*"
End If
My.Computer.FileSystem.CopyDirectory(SourceDirectory, DestinationDirectory)
End Sub
End Class
# 6 Re: Help creating command based application
Thank you for the help. Any suggestions on how to get this to run as a self contained utility instead of an application that installs itself to the start menu?
# 7 Re: Help creating command based application
If by "self-contained," you mean "without requiring the .NET Framework to be installed on the target machine," then you're out of luck: all .NET programs require the .NET Framework on the target machine.
If your target machines already have the .NET Framework installed, you may simply copy your application to them; no need for an installer or Start menu icon.
Another option (but significantly more complex) is something called "ClickOnce deployment," in which you place the app on a Web server or network share, and users install it by simply clicking a link. See http://www.15seconds.com/issue/041229.htm for more information.
# 8 Re: Help creating command based application
I do have the .net framework 1.1, 2.0 and 3.0 on the machines I want the app to run on.
# 9 Re: Help creating command based application
Then all that you should need to roll it out is just the exe itself.
Hack at 2007-11-11 20:50:54 >
