Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old August 19th, 2003, 05:12 AM
rashmi_may rashmi_may is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 2 rashmi_may User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Reading command line arguments in VB

hi all,

i wanted to know how do we read command line arguments in VB program.

regards,
rashmi

Reply With Quote
  #2  
Old August 19th, 2003, 07:52 AM
Anacrusis's Avatar
Anacrusis Anacrusis is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 59 Anacrusis User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Send a message via ICQ to Anacrusis Send a message via AIM to Anacrusis
The arguments get put into a variable called $Command, just check if something is in there:

If Command <> "" then
msgbox "Arguments: " & Command
else
msgbox "No arguments passed"
end if

Reply With Quote
  #3  
Old December 10th, 2003, 03:27 PM
tmangin tmangin is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 8 tmangin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question reading command line args contd..

I'm working on a project where I have to accept arguments in my VB code as well. The problem is this: I need the argument, which is a user name, to be used in a file path. For example:

Public Sub Form_Load()
Call Args
Dim strFileName1 As String
strFileName1 = "C:\iFtpSvc\Hms-ftppro\users\" & CmdArgs & "\" & CmdArgs & ".txt"
Open strFileName1 For Input As 1
Call PrintReport
End Sub

Public Sub Args()
Dim CmdArgs As String
CmdArgs = Command$
'MsgBox CmdArgs
End Sub

When I have the code put the argument in the message box, it works correctly. However, when I try to insert the user name argument in the file path, it does not work. Can anyone help??
If this is not clear enough, please let me know so I can clarify.
Thanks!

Reply With Quote
  #4  
Old December 10th, 2003, 03:31 PM
Anacrusis's Avatar
Anacrusis Anacrusis is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 59 Anacrusis User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Send a message via ICQ to Anacrusis Send a message via AIM to Anacrusis
your not returning the CmdArgs in the sub

before ending the sub put this

Args = CmdArgs

Reply With Quote
  #5  
Old December 10th, 2003, 03:43 PM
tmangin tmangin is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 8 tmangin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
reading command line args

Thanks for your reply, Anacrusis, but it's still not working. I added Args = CmdArgs to the Sub and then changed the Sub to a Function. I get a file not found error because the app can't read the path. Any other suggestions??
Thanks!

Reply With Quote
  #6  
Old February 10th, 2004, 03:27 PM
i6rahim i6rahim is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 1 i6rahim User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Try This

Going with what Anacrusis told you to do. Also ensure that the returned string value is what is being used and not the CmdArgs variable which is only defined locally in the Args function. May also want to do a trim to ensure no extra whitespace that may throw off the search for path.

Public Sub Form_Load()
Dim strFileName1 As String
strFileName1 = "C:\iFtpSvc\Hms-ftppro\users\" & Args.Trim() & ".txt"
Open strFileName1 For Input As 1
Call PrintReport
End Sub

Noticed you had CmdArgs in two places for the file name, so you may have to update your Args function to return an array of strings. Do manipulation of the string values you want in Args function and return to String array in Form_Load(). Then you can say:

strFileName1 = "C:\iFtpSvc\Hms-ftppro\users\" & strArgs(1) & "\" & strArgs(2) & ".txt"

Or you can just manipulate the path in args to be the full path after users, so only you need to put is:
strFileName1 = "C:\iFtpSvc\Hms-ftppro\users\" & Args

Hope that makes sense.

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > Reading command line arguments in VB


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway