?
Solved

How do I pass a veriable into a VB.Net Application

Posted on 2004-11-09
15
Medium Priority
?
182 Views
Last Modified: 2010-04-23
Is it possible to pass variables from the commandline into a VB.Net Application. What I am looking to do is send emails using html format and give the user a hyperlink that will open a program I have already placed on their computer. The hyperlink need to tell the program what the Patient Number and Appointment Number is. I know this can be done in ASP.NET but what about VB.Net.

In ASP.NET it would look like this
http://server/findpatient.asp?AppointmentNumber=55325&PatientNumber=1234

Can this be done in VB.Net? Or is their another way to do this in VB.Net.
0
Comment
Question by:jamescorwin
  • 6
  • 5
12 Comments
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 12534591
The call would look like this:

    YourAppName 55325 1234

Here is the code:

Public Class Form1
    Inherits System.Windows.Forms.Form

    Private ApptNum As Integer
    Private PatNum As Integer

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim args() As String = Microsoft.VisualBasic.Command().Split(" ".ToCharArray)
        If args.GetUpperBound(0) >= 1 Then
            Try
                ApptNum = Integer.Parse(args(0))
                PatNum = Integer.Parse(args(1))
            Catch ex As Exception
                MsgBox("Invalid Appointment or Patient Number")
            End Try
        Else
            MsgBox("Insufficient Parameters")
        End If
        MsgBox("ApptNum = " & ApptNum.ToString & vbCrLf & _
            "PatNum = " & PatNum.ToString)
    End Sub
End Class
0
 

Author Comment

by:jamescorwin
ID: 12536200
I tried this but when I run the execute the program from the commandline as follows
C:\Program Files\SIPCA\InstallEmrInstall\EmrInteractive.exe 55325 1234
I get the following error

Cannot find file C:\Program Files\SIPCA\InstallEmrInstall\EmrInteractive.exe 55325 1234

If I take out the parameters it finds the file and gives the Message "Insufficient Parameters" as it should.
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 12536416
>> when I run the execute the program from the commandline as follows

What code are you using to do this?

~IM
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:jamescorwin
ID: 12536556
I'm not sure if your asking what code am I using in my program or how am I executing the program with parameters. So here is the answer to both.

I'm using the code you showed me in Visual Basic.Net ver 2003. Basically I cut and paste it in.

I'm calling the file by putting
C:\Program Files\SIPCA\InstallEmrInstall\EmrInteractive.exe 55325 1234
in the run box.

I'm also try to all it using <a href> in html within an email. The problem is that windows is not opening
C:\Program Files\SIPCA\InstallEmrInstall\EmrInteractive.exe
then passing 55325 1234 as parameter. Instead windows is trying to open
C:\Program Files\SIPCA\InstallEmrInstall\EmrInteractive.exe 55325 1234
as the whole file name which does not exist.

How should I open this file?
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 12536709
Ok...I see.

I'm not sure if you can create an html link to a local exe that passes parameters in.

Will check it out...

~IM

0
 

Author Comment

by:jamescorwin
ID: 12537235
In what way will this code allow you to open it.
Is it supposed to work from the run box?
Is it only supposed to work from another windows application?
If I could understand how this code will work maybe I can move in that direction.
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 12538340
The code I provided traps parameters passed into the application, which is typically done from the DOS prompt or by Shelling fromm another application.

~IM
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 12590866
Hi jamescorwin,

I have searched high and low for how to pass command-line parameters to an EXE from a URL and can't find a single solution.  I don't think it is possible.

Sorry,

~IM
0
 

Author Comment

by:jamescorwin
ID: 12597121
Thanks anyway... I have been searching as well and I can't find a way to do it either.
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 1000 total points
ID: 12857240
It is possible.  I got a new job recently, and they are doing this there, with no-touch deployment.

Bob
0
 

Author Comment

by:jamescorwin
ID: 13098473
I do not think anyone is able to answer this question as it appears that it's not possible.
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 13098490
Bob said its possible with "no-touch deployment".

Can you explain in a little more detail Bob?

;)
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question