Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 160
  • Last Modified:

Passing parameters to a VB 6.0 program

Is it possible to pass a parameter to a VB 6.0 program.  For instance i want my program to react when a file name has been passed to it.  I know you can change the start up form to Sub Main() but it does not allow you to place a variable inside E.X. Sub Main(Dim CFileName as String).  I know you can do this in C++ when you creat a document program but i cant find a way to do it in VB.
0
TerencDwyer
Asked:
TerencDwyer
  • 2
1 Solution
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
You've placed this question in the VB.net area.

Do you want this for VB6 or VB.Net?
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
In VB6 you can use the Command() function to get the command line parameters.  Then you can split with the space character to break it down into parts as in this example:

Private userName As String
Private password As String
Private dataPath As String

Private Sub Form_Load()
    Dim parameter As Variant
   
    parameter = Split(Command())
    If UBound(parameter) = 2 Then
        userName = parameter(0)
        password = parameter(1)
        dataPath = parameter(2)
       
        Dim msg As String
        msg = "userName = " & userName & vbCrLf & _
            "password = " & password & vbCrLf & _
            "dataPath = " & dataPath
        MsgBox msg
    Else
        MsgBox "Invalid Number of Parameters"
    End If
End Sub
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now