简体   繁体   English

如何以各种形式更新公共财产的价值? VB.net

[英]How to update the value of a public property in all forms? VB.net

This is my code in module1: 这是我在module1中的代码:

Module Module1

Private strMessage As String = Form3.TextBox1.Text
Public Property getMessage() As String
    Get
        Return strMessage
    End Get
    Set(ByVal strCustomerFirstName As String)
        strMessage = strCustomerFirstName
    End Set
End Property

End Module 终端模块

I use Form3 to assign the value to strMessage in module1: 我使用Form3将值分配给module1中的strMessage:

    Public Class Form3
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        getMessage = TextBox1.Text
        Form1.Show()
        Me.Hide
    End Sub
End Class

But when I update the new value in Form3 the value that is displayed in Form1 didn't update at all. 但是,当我在Form3中更新新值时,在Form1中显示的值根本没有更新。 How can I update the value without using the me.close() in form1. 如何在不使用form1的me.close()的情况下更新值。

 Dim numberOfCharactersToDisplay As Integer = 100 Dim scrollingTextSelector As String Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load scrollingTextSelector = getMessage Do Until scrollingTextSelector.Length > (getMessage.Length + numberOfCharactersToDisplay) scrollingTextSelector &= " " & getMessage Loop End Sub 
Private strMessage As String = Form3.TextBox1.Text

Public Property getMessage() As String
    Get
        Return strMessage
    End Get
    Set(ByVal strCustomerFirstName As String)
        strMessage = strCustomerFirstName
        form3.textbox1.text = strMessage
    End Set
End Property

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM