Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have a form which we shall call frm1.

I have a combobox that populates correctly from my database. When my users click on an item in the list and press select, I want to open another form, frm2, pass it the selectedValue from my combobox on frm1 and do another search.

 

How do I get the value to the next form (frm2)?

I know the Selected Value is correct because i built a messagebox to tel lme the value when the button is pressed.

 

Any ideas?

 

 

Andy

Posted

How?

 

Can you provide some example code to create an overload constructor?

 

Basically here is my code:

 

frm1:

 

Public Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
       Dim PassVal As New Frm2()

       intPassedVal = ComboBox1.SelectedValue
              PassVal.Show()

end sub

 

then frm2 has this line in initializecomponent

TextBox2.Text = Frm1.intPassedVal

 

this just leaves me with a blank textbox.

Posted

On my side... I use the Session object which is rather more secure and faster.

You might try to work with overload but the Session object worked fine for me.

 

Session.Add(name,value);

Session[name] = value; // Doesn't work if it's not existent

"If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown

"Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me

"A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend.

C# TO VB TRANSLATOR

Posted

My problem is the opposite of andycharger... Say frm1 generates 5 numbers. To add a new number, frm2.showDialog() is fired. He can pick from some more numbers on this form, frm2. When he finds the one he wants, he clicks OK button.

 

So with this example, how could i send back the number the user picks from frm2 back to the main form, frm1?

Posted
as I said in another post, to pass values between 2 or more forms, I create a module and I declare those public Variables, classes etc in that Module . I can access them from any other form in my project . ;)
Development & Research Department @ Elven Soft
  • *Experts*
Posted

You can also access a public variable without creating a module

In Form1: Public Shared publicInfo(20) As String can be accessed by any form as Form1.publicInfo(0), Form1.publicInfo(1), etc.

 

I personally prefer arrays as they can pass almost anything between forms.

Member, in good standing, of the elite fraternity of mentally challenged programmers.

 

Dolphins Software

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...