Wrox Programmer Forums
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 14th, 2003, 02:58 AM
Registered User
 
Join Date: Aug 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Program arguments

I need to write a program that would launch a webpage depending on the argument values sent to it. It must run from command prompt or from RUN. Something like: notepad.exe %1. This is what I have so far:
----------------------------------
Module code:

Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Public Const conSwNormal = 1

Public Sub vRandomLaunch(someString As String)
    ShellExecute hwnd, "open", "http://www.mywebsite.com/test.asp?someid=" + someString, vbNullString, vbNullString, conSwNormal
End Sub
--------------------------------
Form Code:

Private Sub Form_Load()
    Call vRandomLaunch("123")
    Me.Hide
End Sub

--------------------------------------

How do I pass "123" to the Form on the launch?
I hope this makes sense.
Thanks.

 
Old August 14th, 2003, 03:18 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

The Command function gives you access to command-line arguments passed to your program.

In your example, assuming you ran the program using "YourExe 123" then you would just have
Code:
Private Sub Form_Load()
    Call vRandomLaunch(Command)
    Me.Hide
End Sub





Similar Threads
Thread Thread Starter Forum Replies Last Post
arguments relay pierre.voisin Javascript 1 February 20th, 2008 06:04 PM
take arguments when running program in console iulian C++ Programming 8 January 16th, 2007 09:17 AM
Setup Project: Program not added in Start>Program arif_1947 VS.NET 2002/2003 2 March 31st, 2005 06:40 AM
Arguments snowy0 VB.NET 2002/2003 Basics 3 September 3rd, 2004 08:40 AM
Pass arguments to dos program gregquinn Beginning VB 6 1 December 10th, 2003 05:38 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.