大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
尽量丢掉vb6的习惯,注意对象的作用域及垃圾回收机制,为对象设定适当的范围,如全局对象下面给个示例(从sub main启动):public module sample public sub main() dim frm as new from1("sample form") frm.show windows.forms.application.run() end subend module public class form1 inherts windows.forms.form private btnnew as new windows.forms.button private btnclose as new windows.forms.button public sub new(byval text as string) me.text=text btnnew.text="new form" btnclose.text="exit" btnnew.location=new drawing.point(30,10) btnclose.location=new drawing.point(30,35) me.controls.add(btnnew) me.controls.add(btnclose) addhandler btnnew.click,addressof btnnew_click addhandler btnclose.click,addressof btnclose_click end sub private sub btnnew_click(byval o as object,byval e as eventargs) me.close() dim newform as new form1("new sample form") newform.show() end sub private sub btnclose_click(byval o as object,byval e as eventargs) windows.forms.application.exit() end subend class
创新互联专注为客户提供全方位的互联网综合服务,包含不限于网站建设、做网站、昆山网络推广、重庆小程序开发、昆山网络营销、昆山企业策划、昆山品牌公关、搜索引擎seo、人物专访、企业宣传片、企业代运营等,从售前售中售后,我们都将竭诚为您服务,您的肯定,是我们最大的嘉奖;创新互联为所有大学生创业者提供昆山建站搭建服务,24小时服务热线:18980820575,官方网址:www.cdcxhl.com
Public Class Form1
Dim I As Integer
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
I = I + 1
If I = 10 Then Me.Show()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Hide()
End Sub
End Class
你可以先隐藏窗体 让他加载完 再显示出来 如上代码 如果还不够时间 可以适当增加
直接添加一个MID父窗体或在已有窗体的属性中找到IsMDIContainer属性,然后设置为True,然后创建第二个窗体 ,需要加载子窗体的时候:
Dim NewMDIChild As New Form2
NewMDIChild.MdiParent = Me
NewMDIChild.Show()
Public Shared Sub CheckMDIChildForm(ByVal MDIForm As Windows.Forms.Form, ByVal MDIChildForm As Windows.Forms.Form, ByVal MDIChildFormName As String)
If MDIForm.MdiChildren.Length 1 Then
'如果没有任何一个MDI子窗体,则创该MDI子窗体的窗体实例
Dim MDIChildFrm As Windows.Forms.Form = MDIChildForm ' 定义MDI子窗体
MDIChildFrm.MdiParent = MDIForm '指定父窗体
MDIChildFrm.Show() '打开窗体
Exit Sub
Else
Dim x As Integer
Dim frmyn As Boolean
For x = 0 To (MDIForm.MdiChildren.Length) - 1
Dim tempChild As Windows.Forms.Form = CType(MDIForm.MdiChildren(x), Windows.Forms.Form)
If tempChild.Name = MDIChildFormName Then
'检测到有该MDI子窗体,设为激活 并退出循环
frmyn = True
tempChild.BringToFront()
Exit For
Else
frmyn = False
End If
Next
If Not frmyn Then
'在打开的窗体中没检测到则新建
Dim MDIChildFrm As Windows.Forms.Form = MDIChildForm ' 定义MDI子窗体
MDIChildFrm.MdiParent = MDIForm '指定父窗体
MDIChildFrm.Show() '打开窗体
End If
End If
End Sub
VB.net 加载窗体 form2.show() 卸载窗体 me.close()加载窗体和VB没啥区别,而卸载就截然不同了。附:VB 加载窗体 form2.show 卸载窗体 unload me