|
-
Nov 30th, 2001, 09:25 AM
#1
Thread Starter
Fanatic Member
Command line
How do you work with the command line through VB
1 way i can think of is batch files?
And other?
Seahag
-
Nov 30th, 2001, 09:27 AM
#2
Frenzied Member
u can use shell
shell "notepad",True
-
Nov 30th, 2001, 09:43 AM
#3
Enter arguments directly from the Command prompt or from the Run menu.
Then:
'Read command line arguments.
'Place in code.
'We will read in the entire command line as one string
'"CmdLine" and separate it into (up to 10)
'individual strings (Args).
Dim CmdLine As String
Dim Textline(1 To 80) as String
Dim Args(1 To 10) As String
Dim Beg, I, J As Integer
CmdLine = Command() 'The "Command" function reads the string from the
'command line.
For I = 1 To Len(CmdLine)
Textline(I) = Mid(CmdLine, I, 1)
Next I
For I = 1 To 10
Args(I) = "" 'Initialize all argumenets to NULL.
Next I
'Break the command line down into
'individual argumants.
Beg = 1
For J = 1 To 10
For I = Beg To Len(CmdLine)
If Textline(I) = " " Then
Beg = I + 1
GoTo IncrementJ
End If
Args(J) = Args(J) & Textline(I)
Next I
IncrementJ:
Next J
-
Nov 30th, 2001, 09:52 AM
#4
Thread Starter
Fanatic Member
How about the other direction.
vbGrandpa
I am confused. What does your code do. and where can i use it?
-
Nov 30th, 2001, 10:29 AM
#5
The code parses the command line into separate string values.
"Run someprogram.exe 1 2 3 4 5 6"
Args(1)="1" Args(2)="2"........Args(6)="6"
The program can then use these values as input.
-
Nov 30th, 2001, 10:33 AM
#6
Frenzied Member
what vbGrandpa is saying is:
if you run your program from the command line,
you can send your program parameters,
and to read the parameters, well use vbGrandpa's
code to retrieve them!
But i think your talking about how to run things from vb !
is that it?
-
Nov 30th, 2001, 10:38 AM
#7
Frenzied Member
Easier code
He wants something easy.. so make a program and put this in the starting routine.
Code:
dim sCmd as string
sCmd = Command()
msgbox sCmd 'msgbox the command line
-
Nov 30th, 2001, 11:50 AM
#8
Frenzied Member
Isnt that what you need. Just reply... I can get different code, or explain anything.
-
Nov 30th, 2001, 12:46 PM
#9
Thread Starter
Fanatic Member
Hello all..
I thought this would be simple.. but is turning out to be something all so ver new..
Evan.. I think you on the right trak. I dont understand how to use what u put.
how (no shell) would you open NotePad.. or use copy c:\my.exe, c:\windows\my.exe
I know you can make a batch file and run it.. I was looking for a mor direct route?
Thanks everyone for helping.
Seahag
-
Nov 30th, 2001, 12:50 PM
#10
Frenzied Member
Oh. You use a API. But... Your still shelling.
So the point of that.. well there isnt any.
-
Nov 30th, 2001, 12:56 PM
#11
Thread Starter
Fanatic Member
Good enough for me.
I hate typing... and I dont understand API, other than is WORKS..?
Thanks all
-
Nov 30th, 2001, 01:12 PM
#12
Frenzied Member
There is one api that will execute the program associated with the files.. like you execute a txt file and it will notepad.
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
|