Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Opening a VB.net with a variable

Posted on 2011-09-14
4
Medium Priority
?
294 Views
Last Modified: 2012-05-12
Hi All

I'm trying to make my vb.net project bigger, the next step is to be able to click on a link an open a  form within the program. Eg. customer detail with ID 23547.

How would i go about this? I already have the sub process to open the section within the program but i need the bit to be able to pass a variable in to the program.

Cheers

Matt
0
Comment
Question by:Matb396
  • 2
4 Comments
 
LVL 13

Expert Comment

by:Philip Pinnell
ID: 36535167
You can create a contructor for the second form that accepts a parameter

  public partial class Form2 : Form
  {
    private string strPassedText = "No parm";
    public Form2()
    {
      InitializeComponent();
    }
    public Form2(string strParm)
    {
      InitializeComponent();
      strPassedText = strParm;
    }

    private void Form2_Load(object sender, EventArgs e)
    {
      this.label1.Text = strPassedText;
    }
  }

Then call it as follows

    private void button1_Click(object sender, EventArgs e)
    {
      Form2 myform2 = new Form2("Hello World");
      myform2.Show();

    }

   
0
 

Author Comment

by:Matb396
ID: 36535193
Im on about a link from an email or something... so one of the empolyees can email the manager say "look at x y z " & Link... so when the link is clicked on the program auto loads up the a part within the program.

I need to know how to pass that variable in to a program?
0
 
LVL 7

Accepted Solution

by:
Ironhoofs earned 2000 total points
ID: 36535234
If you are refering to command line parameters (i.e.: yourprogram.exe myparm) you can find a short tutorial here:

http://msdn.microsoft.com/en-us/library/aa288457%28v=vs.71%29.aspx

0
 

Author Comment

by:Matb396
ID: 36535275
ok that works how do you do something like spotify does, and have a much nice looking link like so

spotify:track:6MMCgZUbWHzjCoU5OgLMni

rather then :

O:\Delelopment\Freatures\CommandLineFeature\CommandLineFeature\bin\Release\CommandLineFeature.exe /CusID233454

So for example

CommandLineFeature:CusID233454


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.

Question has a verified solution.

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

What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
When you discover the power of the R programming language, you are going to wonder how you ever lived without it! Learn why the language merits a place in your programming arsenal.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Starting up a Project

876 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