PageRenderTime 38ms CodeModel.GetById 17ms RepoModel.GetById 0ms 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. Pass Value Between Forms Sample
  4. ===============================================================================
  5. /////////////////////////////////////////////////////////////////////////////
  6. Summary:
  7. The Pass Value Between Forms sample demonstrates how to pass value between forms.
  8. There're two common ways to pass value between forms:
  9. 1. Use a property.
  10. Create a public property on the target form class, then we can pass value
  11. to the target form by setting value for the property.
  12. 2. Use a method.
  13. Create a public method on the target form class, then we can pass value to
  14. the target form by passing the value as parameter to the method.
  15. /////////////////////////////////////////////////////////////////////////////
  16. Code Logic:
  17. 1. Create two forms named FrmPassValueBetweenForms and
  18. FrmPassValueBetweenForms2 respectively;
  19. 2. Create a public property named ValueToPassBetweenForms in the
  20. FrmPassValueBetweenForms2 class;
  21. private _valueToPassBetweenForms As String;
  22. Public Property ValueToPassBetweenForms() As String
  23. Get
  24. Return Me._valueToPassBetweenForms
  25. End Get
  26. Set(ByVal value As String)
  27. Me._valueToPassBetweenForms = value
  28. End Set
  29. End Property
  30. 3. Create a public method named SetValueFromAnotherForm in the
  31. FrmPassValueBetweenForms2 class;
  32. Public Sub SetValueFromAnotherForm(ByVal val As String)
  33. Me._valueToPassBetweenForms = val
  34. End Sub
  35. 4. On the FrmPassValueBetweenForms form, handle the Click event of the buttons.
  36. In the Click event handler of button1, set the SetValueFromAnotherForm
  37. property for the FrmPassValueBetweenForms2 to pass the text value from
  38. FrmPassValueBetweenForms to FrmPassValueBetweenForms2.
  39. In the Click event handler of button2, call the SetValueFromAnotherForm
  40. method and pass the text value as parameter to the FrmPassValueBetweenForms2.
  41. /////////////////////////////////////////////////////////////////////////////
  42. References:
  43. 1. Windows Forms General FAQ.
  44. http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/77a66f05-804e-4d58-8214-0c32d8f43191
  45. /////////////////////////////////////////////////////////////////////////////