Help with calling form

sunnyjulka

Member
Joined
Sep 12, 2005
Messages
17
Programming Experience
1-3
Hi this is a very simple problem, but I cannot get over it.
I have a grid on my main form(Inventory.vb) and the grid displays the items in the inventory table. I have a method "look" in the class, which takes the Product ID as parameter and this method selects the row in the grid, with the product Id given by the parameter. Now the user has to enter the Product ID in a textbox or othe way. If I let the user enter it in a textbox, every thing is good in my application. But I want that another form is populated and it has a textbox and a button. The user clicks the button and the value is passed to Inventory.vb . It looks very simple, maybe I ma just missing soething very minor here. Any recommendation.
Thanks in advance.
 
There are a few ways of doing this but I like to use events to achieve the effect.

In NewForm (with textbox and button)

VB.NET:
'in declarations at the top
Public Event IDSelected(Byval MyID as integer)

'in button click event
RaiseEvent IDSelected(CInt(TextBox1.Text)) 
'Replace TextBox1 with your own textbox

In Inventory Form:-

VB.NET:
Private Sub HandleIDSelected(Byval SelectedID as integer)
Look(SelectedID)
End Sub

'Place the following where you declare the New Form (Which I'm going to call InputForm)

Dim MyInputForm as New InputForm

'Create an event handler

AddHandler MyInputForm.IDSelected, AddressOf HandleIDSelected

'Show the form
MyInputForm.Show


Hope This helps..
 
Hi BadgerByte
Thanks a lot. It works with your code..
I spent more than 4 hours on this problem...and I could not get it..
seems like you are pretty sharp..
thanks again...
hey also if I have other question can I PM you..
 
Hey,

No problem sir. Feel free to PM me, however it's often better to Post a general thread as there are a lot of people who know a great deal more than me here, and I won't always be online. :)

Glad you got it working.
 
Back
Top