PageRenderTime 18ms CodeModel.GetById 14ms app.highlight 1ms RepoModel.GetById 2ms app.codeStats 0ms

/Visual Studio 2008/VBWinFormPassValueBetweenForms/ReadMe.txt

#
Plain Text | 69 lines | 45 code | 24 blank | 0 comment | 0 complexity | a92cfb5edd961b578a611dbb6c5b7404 MD5 | raw file
 1================================================================================
 2  WINDOWS FORMS APPLICATION : VBWinFormPassValueBetweenForms Project Overview
 3       
 4                        Pass Value Between Forms Sample
 5                        
 6===============================================================================
 7
 8/////////////////////////////////////////////////////////////////////////////
 9Summary:
10
11The Pass Value Between Forms sample demonstrates how to pass value between forms.
12 
13There're two common ways to pass value between forms:
14
151. Use a property.
16
17   Create a public property on the target form class, then we can pass value 
18   to the target form by setting value for the property.
19
202. Use a method.
21
22   Create a public method on the target form class, then we can pass value to 
23   the target form by passing the value as parameter to the method.
24   
25
26/////////////////////////////////////////////////////////////////////////////
27Code Logic:
28
29   1. Create two forms named FrmPassValueBetweenForms and 
30      FrmPassValueBetweenForms2 respectively;
31      
32   2. Create a public property named ValueToPassBetweenForms in the 
33      FrmPassValueBetweenForms2 class;
34      
35      private _valueToPassBetweenForms As String;
36
37      Public Property ValueToPassBetweenForms() As String
38        Get
39            Return Me._valueToPassBetweenForms
40        End Get
41        Set(ByVal value As String)
42            Me._valueToPassBetweenForms = value
43        End Set
44      End Property
45
46      
47   3. Create a public method named SetValueFromAnotherForm in the 
48      FrmPassValueBetweenForms2 class;
49      
50      Public Sub SetValueFromAnotherForm(ByVal val As String)
51        Me._valueToPassBetweenForms = val
52      End Sub
53      
54   4. On the FrmPassValueBetweenForms form, handle the Click event of the buttons.
55      In the Click event handler of button1, set the SetValueFromAnotherForm 
56      property for the FrmPassValueBetweenForms2 to pass the text value from 
57      FrmPassValueBetweenForms to FrmPassValueBetweenForms2.
58      In the Click event handler of button2, call the SetValueFromAnotherForm 
59      method and pass the text value as parameter to the FrmPassValueBetweenForms2.
60
61
62/////////////////////////////////////////////////////////////////////////////
63References:
64   
651. Windows Forms General FAQ.
66   http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/77a66f05-804e-4d58-8214-0c32d8f43191
67   
68
69/////////////////////////////////////////////////////////////////////////////