Link to home
Start Free TrialLog in
Avatar of Matb396
Matb396

asked on

Opening a VB.net with a variable

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
Avatar of Andrew Crofts
Andrew Crofts
Flag of Ukraine image

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();

    }

   
Avatar of Matb396
Matb396

ASKER

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?
ASKER CERTIFIED SOLUTION
Avatar of Ironhoofs
Ironhoofs
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Matb396

ASKER

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