In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article is about how VB.NET forms pointers are passed in a project. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
The transfer of VB.NET form pointer in the project
In addition to globalizing the form instance, you can also save the VB.NET form pointer in a variable and pass it to the routine that needs to access the form. Suppose you have a form Form1 and you want to open the second form Form2 when you click one of the buttons in Form1 (Button1), and then do some calculation when you click another button (Button2) in the second form Form2. You can write the entire code in Form1, that is:
Public Class Form1 Inherits System.Windows.Forms.Form Dim myForm2 As Form2 Private Sub Button1_Click (ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button1.Click myForm2 = New Form2 () myForm2.Show () End Sub Private Sub Button2_Click (ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button2.Click Calculations.CompoundInterestCalc (myForm2) End Sub End Class
It is possible to globalize the VB.NET form pointer or pass it as an argument. However, you must choose the solution according to the needs of the project. When there are only a few procedures in a .NET project that need to access a particular form, I recommend that you add a parameter to those procedures to accept VB.NET form pointers if necessary. When your project has too many procedures to access the form, you should consider setting a global VB.NET form pointer variable. Of course, you are still considering adjusting the code structure of the project so that there is only one class or procedure that actually accesses the form. If you want to use the form to display login information, you can first create a class, save the form instance as its Shared class member, and then add a Shared method WriteToLogWindow to complete the actual form access. Therefore, any code in the project can indirectly access the form that displays login information simply by calling this WriteToLogWindow method:
Public Class Log Private Shared m_LogForm As Form2 Public Shared Property LogForm () As Form2 Get Return m_LogForm End Get Set (ByVal Value As Form2) m_LogForm = Value End Set End Property Public Shared Sub WriteToLogWindow (ByVal Message As String) Dim sb As New _ StringBuilder (m_LogForm.txtLogInfo.Text) sb.Append (Environment.NewLine) sb.Append (Message) m_LogForm.txtLogInfo.Text = sb.ToString () End Sub End Class Thank you for reading! This is the end of this article on "how to pass VB.NET form pointers in the project". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.