Results 1 to 10 of 10

Thread: Calling an app within an app

  1. #1

    Thread Starter
    Hyperactive Member vbuser1976's Avatar
    Join Date
    Sep 2000
    Location
    Yonkers, NY
    Posts
    404

    Question Calling an app within an app

    Hi everyone!

    Ok, let me get down to business . I have created two separate, independent apps. I want to call one from the other application. I know how to call it but I need to know how can I get the called application to automatically log in with a username and password.

    Initially, the called app, if used independently, will start with a login screen. I want to bypass that when I call the app through my other app. Any ideas out there? Thanks in advance. I hope I have not confused anyone.
    -vbuser1976
    VB6 Enterprise SP6
    SQL 7.0 SP2
    VBScript, HTML, Javascript, C++, a little UNIX

  2. #2
    Frenzied Member vbgladiator's Avatar
    Join Date
    May 2001
    Posts
    1,950
    You can send the username and password as the command line arguments. Then add code in the other application that will check if the username and password are correct. If so, show the main form instead of the login screen.

  3. #3
    Frenzied Member oh1mie's Avatar
    Join Date
    Sep 2001
    Location
    Finland
    Posts
    1,043

    Re: Calling an app within an app

    Originally posted by vbuser1976
    Hi everyone!

    Ok, let me get down to business . I have created two separate, independent apps. I want to call one from the other application. I know how to call it but I need to know how can I get the called application to automatically log in with a username and password.

    Initially, the called app, if used independently, will start with a login screen. I want to bypass that when I call the app through my other app. Any ideas out there? Thanks in advance. I hope I have not confused anyone.
    Use command to pass data to another programm
    oh1mie/Vic


  4. #4

    Thread Starter
    Hyperactive Member vbuser1976's Avatar
    Join Date
    Sep 2000
    Location
    Yonkers, NY
    Posts
    404

    Question hmm...

    Originally posted by vbgladiator
    ...Then add code in the other application that will check if the username and password are correct. If so, show the main form instead of the login screen.
    Can you please show me an example of this? For assignment of parameters, do I use the name of the textbox or create a global variable name?
    -vbuser1976
    VB6 Enterprise SP6
    SQL 7.0 SP2
    VBScript, HTML, Javascript, C++, a little UNIX

  5. #5
    Frenzied Member vbgladiator's Avatar
    Join Date
    May 2001
    Posts
    1,950
    Use Command$ in the called application to get the command line arguments. You can separate the username and password by a comma to easily separate them.

    In you startup routine.

    Code:
    dim sArgs as string
    sArgs = Command$
    
    If len(sArgs) = 0 then  'username and password wasn't send
        LoginForm.Show
    else
        'username and password was sent.  Check for the username    and password if they are correct.  If so then
        MainForm.Show
    end if

  6. #6

    Thread Starter
    Hyperactive Member vbuser1976's Avatar
    Join Date
    Sep 2000
    Location
    Yonkers, NY
    Posts
    404

    Thumbs up need more info...

    Thank you for your input. First, what should the line calling the app look like? This is what I have so far:

    Shell "C:\Program Files\Folder1\express.exe" what do I add after this to let the app know that I am passing parameters?

    Second, how do I , or do I need to, assign these parameters to variables in the called app for it to check the connection(verify the username and password)? Sorry for asking you these questions, I feel like a dunce .

    Thanks again for all your input.
    -vbuser1976
    VB6 Enterprise SP6
    SQL 7.0 SP2
    VBScript, HTML, Javascript, C++, a little UNIX

  7. #7
    Frenzied Member vbgladiator's Avatar
    Join Date
    May 2001
    Posts
    1,950
    First Line - Shell "C:\Program Files\Folder1\express.exe UserName,Password

    Yes, you do need to assign these to variables.

    Code:
    dim sUser as string
    dim sPass as string
    
    sUser = Left$(Instr(1,command$, ",") -1)
    sPass = Left$(Instr(1,command$, ",")+1)
    
    Now, check if they're correct
    You might have to play with -1 and +1. I'm not doing this on a computer.

  8. #8

    Thread Starter
    Hyperactive Member vbuser1976's Avatar
    Join Date
    Sep 2000
    Location
    Yonkers, NY
    Posts
    404

    Unhappy getting an error...

    I am getting an error with the code above. Here it is:

    Compile error:
    Variable required - can't assign to this expression.

    the 'this' the error speaks of is : Command$. I don't think this works in VB6, it might work if you are using Access to create apps, but I am not. Any ideas? thanks again.
    -vbuser1976
    VB6 Enterprise SP6
    SQL 7.0 SP2
    VBScript, HTML, Javascript, C++, a little UNIX

  9. #9
    Fanatic Member vb_dba's Avatar
    Join Date
    Jun 2001
    Location
    Somewhere aloft between the real world and insanity
    Posts
    1,016
    Change the following:
    VB Code:
    1. sUser = Left$(command$, Instr(1,command$, ",") -1)
    2. 'Changed this after inital post
    3. sPass = Right$(command$, Len(command$) - Instr(1,command$, ",")+1)

    Chris
    Chris

    Master Of My Domain
    Got A Question? Look Here First

  10. #10

    Thread Starter
    Hyperactive Member vbuser1976's Avatar
    Join Date
    Sep 2000
    Location
    Yonkers, NY
    Posts
    404

    Thumbs up THANX!

    Thank you all! That was what I was looking for. The Right$ code needed a little tweaking (i.e. not including the " + 1" at the end) but it is working.

    Kudos to you all!
    -vbuser1976
    VB6 Enterprise SP6
    SQL 7.0 SP2
    VBScript, HTML, Javascript, C++, a little UNIX

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width