设Form1 为主窗体
Form2 为登录窗体
Form3 为主窗体的子窗体
Button1 为Form2上的按键(即进入Form3的按钮)
--------Form1---------
Public Class Form1
Public Year As String
Public Year1 As String
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Form1.Load
me.Label1.Text=Year
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Form3.Year1 = Label1.Text
End Sub
--------Form2---------
在登录窗体 Form2 有登陆日期(年份)文本框 TextBox1
Private Sub Form2_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
Form1.Year= TextBox1.Text
'Year 登录窗体中的文本框输入的值,当登录窗体关闭后主窗体能获得登陆该值
End Sub
--------Form3---------
Public Class Form3
Public Year1 As String
Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
me.Label1.Text = Year1
End Sub
这样,在登录窗体关闭后主窗体能获得此参数。此时主窗体是打开的,再单击进入其他窗体也能获得此项参数。其他参数以此类推。
这是我这几天的一点收获,也感谢各位高手!希望与爱好者共享。陈德勇