PageRenderTime 50ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/Visual Studio 2008/VBWinFormPassValueBetweenForms/Form2.vb

#
Visual Basic | 58 lines | 23 code | 10 blank | 25 comment | 0 complexity | 4b3924818e0f33c3eba97ffd5b4fb5f3 MD5 | raw file
  1. '************************************* Module Header **************************************\
  2. ' Module Name: Form2.vb
  3. ' Project: VBWinFormPassValueBetweenForms
  4. ' Copyright (c) Microsoft Corporation.
  5. '
  6. ' This sample demonstrates how to pass value between forms.
  7. '
  8. ' There're two common ways to pass value between forms:
  9. '
  10. ' 1. Use a property.
  11. ' Create a public property on the target form class, then we can pass value to the target
  12. ' form by setting value for the property.
  13. '
  14. ' 2. Use a method.
  15. ' Create a public method on the target form class, then we can pass value to the target
  16. ' form by passing the value as parameter to the method.
  17. '
  18. ' This source is subject to the Microsoft Public License.
  19. ' See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
  20. ' All other rights reserved.
  21. '
  22. ' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
  23. ' EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
  24. ' WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
  25. '******************************************************************************************/
  26. Public Class Form2
  27. Inherits Form
  28. Public Sub New()
  29. MyBase.New()
  30. InitializeComponent()
  31. AddHandler Load, AddressOf Me.FrmPassValueBetweenForms2_Load
  32. End Sub
  33. Private Sub FrmPassValueBetweenForms2_Load(ByVal sender As Object, ByVal e As EventArgs)
  34. Me.lbDisplay.Text = Me._valueToPassBetweenForms
  35. End Sub
  36. Private _valueToPassBetweenForms As String
  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. Public Sub SetValueFromAnotherForm(ByVal val As String)
  46. Me._valueToPassBetweenForms = val
  47. End Sub
  48. End Class