Returning a Value from a Visual Basic .NET Form

 <  Day Day Up  >  

The preceding example introduced an additional feature, FoxPro's ability to RETURN a value from the UNLOAD event of a modal form. In Visual Basic .NET, the preferred method is to instantiate the form, but only hide it in the code that closes the search form. To call the form in Visual Basic .NET, you use this:

 

 Dim frm as New frmFindCustomer Frm.ShowDialog() 

The frmFindCustomer class should have a Public field (recall that what we would call a property or a public variable in Visual FoxPro is called a field in a .NET class) in which the search form stores either the value to return, or a null string if the user selected Cancel. Then you simply store the value of the form's field and close the form. Listing 9.4 shows the complete code.

Listing 9.4. Returning a Value from a Visual Basic. NET Search Form
 Dim frm as New frmFindCustomer Frm.ShowDialog() SelectedValue = Frm.KeyValue Frm.Close()  ' or Frm.Dispose() Cmd = "SELECT * FROM Customers WHERE CustomerID="  + SelectedValue 

 <  Day Day Up  >  


Visual Fox Pro to Visual Basic.NET
Visual FoxPro to Visual Basic .NET
ISBN: 0672326493
EAN: 2147483647
Year: 2004
Pages: 130
Authors: Les Pinter

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net